FileDocCategorySizeDatePackage
CPUScheduler1.javaAPI DocExample2125Thu Feb 04 16:10:38 GMT 1999None

CPUScheduler

public class CPUScheduler extends Thread

Fields Summary
private int
timeslice
private CircularList
threads
public boolean
shouldRun
Constructors Summary
public CPUScheduler(int t)

								// Exit when this is set

	   
		threads = new CircularList();
		timeslice = t;
	
Methods Summary
public voidaddThread(java.lang.Thread t)

		threads.insert(t);
		t.setPriority(2);
	
public voidremoveThread(java.lang.Thread t)

		t.setPriority(5);
		threads.delete(t);
	
public voidrun()

		Thread current;
		setPriority(6);
		while (shouldRun) {
			current = (Thread) threads.getNext();
			if (current == null)
				return;
			current.setPriority(4);
			try {
				Thread.sleep(timeslice);
			} catch (InterruptedException ie) {};
			current.setPriority(2);
		}