The class T1
extends Thread
class.
More...
Public Member Functions | |
T1 (JPWorld parent, float sleepIntervalSec) | |
Creates a new instance of T1. | |
void | start () |
Starts the thread. | |
void | stopThread () |
Stops the thread. | |
void | interruptibleSleep (long millis) |
Interruptible sleep (instead of Thread.sleep ). | |
void | run () |
Prints thread's own signature and creates a pair of particles in belonging JPWorld 's context every sleepItervalMillis . | |
Protected Attributes | |
JPWorld | parent |
Parent where println() messages are directed to. | |
Private Attributes | |
String | signature = "T1: Thread 1" |
volatile boolean | running = false |
Indicates if thread is (or should be) running. | |
volatile boolean | completed = true |
Indicates that thread is completed. | |
int | sleepItervalMillis |
Sleep interval for thread in millis. |
The class T1
extends Thread
class.
Instance of the T2
prints out its signature until it gets stopped. It also creates a charged particle pair in associated JPWorld
context.
Definition at line 10 of file T1.java.
T1.T1 | ( | JPWorld | parent, |
float | sleepIntervalSec | ||
) |
Creates a new instance of T1.
parent | owner of the thread |
sleepIntervalSec | sleep interval in seconds |
Definition at line 40 of file T1.java.
References parent, and sleepItervalMillis.
Referenced by T3.run().
{ this.parent = parent; this.sleepItervalMillis = (int)( sleepIntervalSec * 1000f ); }
void T1.interruptibleSleep | ( | long | millis ) |
void T1.run | ( | ) |
Prints thread's own signature and creates a pair of particles in belonging JPWorld
's context every sleepItervalMillis
.
Reimplemented in T3.
Definition at line 90 of file T1.java.
References completed, JPWorld.createPairOfChargedParticles(), interruptibleSleep(), parent, JPWorld.println(), running, signature, and sleepItervalMillis.
{ while( running ) { parent.println( signature ); parent.createPairOfChargedParticles( 1, 10.0 + Math.random () * 5.0 ); interruptibleSleep( sleepItervalMillis ); } completed = true; }
void T1.start | ( | ) |
void T1.stopThread | ( | ) |
volatile boolean T1.completed = true [private] |
volatile boolean T1.running = false [private] |
Indicates if thread is (or should be) running.
Definition at line 17 of file T1.java.
Referenced by run(), start(), and stopThread().
String T1.signature = "T1: Thread 1" [private] |
int T1.sleepItervalMillis [private] |