All Packages  This Package  Class Hierarchy  Class Search  Index

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

  Summary

public class  TimeSlicer
     extends java.lang.Object
     implements java.lang.Runnable
{
          // Constructors 1
     public TimeSlicer(int);

          // Methods 4
     public synchronized void addThread(Thread);
     public void run();
     public synchronized void start();
     public synchronized void stop();
}

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




  Constructors

· TimeSlicer

Summary  |  Top

   public TimeSlicer(int base_priority) 


  Methods

· run

Summary  |  Top
   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, ...

Implements:
run in interface Runnable


· start

Summary  |  Top
   public synchronized void start() 


· stop

Summary  |  Top
   public synchronized void stop() 


· addThread

Summary  |  Top
   public synchronized void addThread(Thread thread) 


All Packages  This Package  Class Hierarchy  Class Search  Index
Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7