The Thread Class
© 2012, Martin Rinehart
Thread class is explained in some detail in our Threads page. This page summarizes the API.
WARNING: These are not real threads. They do not permit the use of multiple cores on a multicore CPU. They will not divide long-running processes into smaller parts.
The Thread Constructor
var my_thread = new MRlib323.Thread( runnable );
A "runnable" object is any object with a
Note: The constructor passes its parameters to an
init() method that can be called by the constructor (or
init() method) of a class that extends
The Thread Methods
my_thread.sleep( millis );
sleep() method pauses a running thread for
With no arguments, the
start() method will call
runnable.run() just once. This method is useful during debugging.
start( millis ) Method
my_thread.start( number_of_millis )
This is the standard
start() method. It begins running the
runnable.run() method, then pauses for
number_of_millis and then repeats, until the
Thread.stop() method is called.
start( millis, number_of_runs ) Method
my_thread.start( nillis, ntimes )
This version of
start() repeats the
runnable.run() method, with
millis delays between them, for the specified number of repetitions and then stops.
Stops executions of the
runnable.run() method. (An indefinite pause, waiting on a subsequent
my_thread.stop( num )
Stops execution after
num more executions of
runnable.run(). (An indefinite pause, waiting on a subsequent
... '' + my_thread ...
Used during development.
Feedback: MartinRinehart at gmail dot com
# # #