com.syncbuilder.util
Class TimeSlicer

java.lang.Object
  |
  +--com.syncbuilder.util.TimeSlicer

public class TimeSlicer
extends java.lang.Object
implements java.lang.Runnable

This class simulates time-sliced multi-threading on a system that can only provide round-robin green threads.


Constructor Summary
TimeSlicer(int base_priority)
           
 
Method Summary
 void addThread(java.lang.Thread thread)
           
 void run()
          The core of the scheduler.
 void start()
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeSlicer

public TimeSlicer(int base_priority)
Method Detail

run

public void run()
The core of the scheduler. It works like this: There is one master thread which runs with a priority of base_priority + 2 (this run()-method actually is the run()- method of that thread). This master thread takes one of the threads it is supposed to schedule, raises that thread's priority to base_priority + 1, and then goes to sleep, thus giving the thread with the raised priority a chance to run. When the master thread wakes up, it puts the thread's priority back to base_priority, like all the other threads, and picks the next thread for execution, raises that thread's priority, ...
Specified by:
run in interface java.lang.Runnable

start

public void start()

stop

public void stop()

addThread

public void addThread(java.lang.Thread thread)


This material is Copyrighted (C) 1999 by Tilo Christ. All Rights Reserved.