8.72. File tom/Thread

class tom.Thread

The Thread class provides an abstraction to the multi-threading facilities provided by the underlying operating system.

A new thread is started by the performInThread with method provided by the instance All. The value returned by that method is the Thread object of the newly created thread.

Every thread has an id. The id of the current thread is available from the Thread class as current_id. The main thread (which every program has, even when running single-threaded) has id 0. Due to the differences in target implementations, exiting the main thread, by invoking that Thread's exit method, is not guaranteed not to exit the program.

Multi-threading need not be available on all TOM targets. The functioning method returns FALSE on those targets on which multi-threading is not available. However, a TOM programmer can assume multi-threading to always be available.

inherits

State supers: State

variables

static MutableEqSet threads;

The currently existing threads.

local static public instance (id) current;

The current thread.

local static public int current_id;

The id of the current thread.

methods


boolean
  functioning;

Return TRUE iff we can run multiple threads on this target.


Set
  threads;

Return the currently existing threads.

instance tom.Thread

variables

public int thread_id;

The TOM thread id of this thread.

methods


void
  exit int rc
pre
  self == [Thread current];

Exit the receiving thread, which must be the current thread.


protected id (self)
  init int th_id;

Designated initializer.