Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.metacosm.framework.server
Class Schedule  view Schedule download Schedule.java

java.lang.Object
  extended byorg.metacosm.framework.server.Schedule
All Implemented Interfaces:
java.lang.Runnable

public final class Schedule
extends java.lang.Object
implements java.lang.Runnable

The scheduler for a Metacosm game.
Use:

 Schedule schedule = new Schedule(this); // called by Game
 schedule.start();
 ...
 schedule.stop();
 


Field Summary
private  boolean nonStop
          A variable to allow the thread to end.
private  Scheduler scheduler
          The Scheduler used for the loop.
private  java.lang.Thread thread
          The Thread containing the loop.
private  boolean threadSuspended
          A variable containing the state of the loop.
 
Constructor Summary
Schedule()
          This should be the default constructor.
Schedule(Scheduler scheduler)
          It is an alternative constructor for this class.
 
Method Summary
 void pause()
          Pauses the loop.
 void processTurn()
          Runs one turn.
 void resume()
          Resumes a pause.
 void run()
          Implements Runnable.
 void setScheduler(Scheduler scheduler)
          Sets a Scheduler.
 void start()
          Starts the loop.
 void stop()
          Definitely stops the loop.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

thread

private java.lang.Thread thread
The Thread containing the loop.


threadSuspended

private volatile boolean threadSuspended
A variable containing the state of the loop.


nonStop

private volatile boolean nonStop
A variable to allow the thread to end.


scheduler

private Scheduler scheduler
The Scheduler used for the loop.

Constructor Detail

Schedule

public Schedule()
This should be the default constructor.


Schedule

public Schedule(Scheduler scheduler)
It is an alternative constructor for this class.

Method Detail

setScheduler

public void setScheduler(Scheduler scheduler)
Sets a Scheduler. May be used by a game manager.


run

public void run()
Implements Runnable. Actually it is The Loop. This method must NEVER be executed directly.

Specified by:
run in interface java.lang.Runnable

start

public void start()
Starts the loop.


pause

public void pause()
Pauses the loop.


resume

public void resume()
Resumes a pause.


stop

public void stop()
Definitely stops the loop.


processTurn

public void processTurn()
Runs one turn. Is effective only during pauses.