threads

Basic multithreading support.
Thread( [name], functionToRun ) constructor
Thread.start()
Thread.alive read-only
Thread.name read-only
Thread.interrupt()
Thread.interrupted static
Thread.join( [msTimeout] )
Thread.hasReturnValue read-only
Thread.returnValue read-only
Thread.busyWindow( task, [title], [canCancel] ) static
Thread.run( functionToRun ) static
Thread.invokeLater( functionToRun ) static
Thread.invokeAndWait( functionToRun ) static
Thread.Lock : java.util.concurrent.locks.ReentrantLock constructor static

Basic multithreading support.

Thread( [name], functionToRun ) constructor

Create a new thread that will execute functionToRun.

Note: Any calls into Strange Eons from the background thread must be made on the event dispatch thread. (Use Thread.invokeLater() or Thread.invokeAndWait().)

name an optional name for the thread
functionToRun a function to run in another thread

Thread.start()

Starts executing functionToRun in parallel with the caller. Threads cannot be run multiple times.

Thread.alive read-only

This is true if the thread has been started but has not yet finished.

true if the thread is running

Thread.name read-only

Returns the name of the thread.

returns the name used to create this Thread

Thread.interrupt()

Sets the thread's interruption flag.

Thread.interrupted static

This is true if the currently running thread has been interrupted. Checking this value clears it to false until the next time the thread is interrupted.

Thread.join( [msTimeout] )

Causes the current thread to wait until this thread ends. If the optional msTimeout is given, the current thread will stop waiting after that many milliseconds.

msTimeout the maximum time to wait, in ms (default is to wait forever)

returns the value returned by the Thread's functionToRun, if the function returns a value and the thread ended before the timeout elapsed

Thread.hasReturnValue read-only

This is true if this thread has completed normally (without throwing an uncaught exception). If the thread has not been started or is still alive, then it returns false. Note that this property does not indicate whether the function actually returned anything, only that if it did, it is now available to be read.

Thread.returnValue read-only

If the thread has been started and the thread's functionToRun has finished executing without throwing an uncaught exception, then this property will store the value returned by the function, if any. If the thread ended due to an uncaught exception, then reading this property will cause the exception to be thrown.

Thread.busyWindow( task, [title], [canCancel] ) static

Runs a lengthy task in the background while providing feedback to the user. When this function is called, the user interface will be blocked by a status window while the function task executes. This function will be passed a single argument, an object with the following properties:

maximumProgress sets the integer number of "steps" needed to complete the task;
the definition of a step is left up to the task function
currentProgress sets the highest completed step to a value between 0 and maximumProgress (inclusive)
title sets the main title of the feedback display
status sets the text of a smaller text description at the bottom of the feedback display
cancelled gets a boolean value that is true if the user has clicked the cancel button

The feedback window displays a progress bar that will indicate that the task's completedness is proportional to currentProgress/maximumProgress. If no maximum is set, the progress bar will indicate that an indeterminate amount of time is required by the task. If canCancel is true then the feedback window will include a Cancel button. If used, the task should periodically check if this button has been pressed using the cancelled property, and quit the task as soon as possible if it is true. (This will always be false if the Cancel button was not requested.)

task a function to be run in the background
title the initial title to use for the feedback display
canCancel if true, the feedback display will include a Cancel button

Thread.run( functionToRun ) static

Starts a new thread. This is a convenience that creates a new Thread and immediately start()s it. The new Thread is returned.

returns the new Thread

Thread.invokeLater( functionToRun ) static

Run a task on the event dispatch thread without waiting for it to return. For example:
 Thread.invokeLater(
     function() {
         println( "I will be called later." );
     }
 );
 println( "I will be called now." );

Thread.invokeAndWait( functionToRun ) static

Run a task on the event dispatch thread, waiting for it to return. If the current thread is the event dispatch thread, then it will run immediately. Otherwise, the current thread will be paused until the event dispatch thread is able to execute the function.

Returns the result returned by functionToRun, or undefined if the task throws an exception

Thread.Lock : java.util.concurrent.locks.ReentrantLock constructor static

This is a convenient reference to the class java.util.concurrent.locks.ReentrantLock that can be used for synchronization purposes.

Contents