Titanium ThreadGroup API

Ti.lang.ThreadGroup

Variable Index

 o MAX_PRIORITY
The maximum priority that a threadgroup can have.
 o MIN_PRIORITY
The minimum priority that a threadgroup can have.
 o NORM_PRIORITY
The default priority that is assigned to a threadgroup.

Constructor Index

 o ThreadGroup()
Allocates a new ThreadGroup object.
 o ThreadGroup(Runnable)
Allocates a new ThreadGroup object.
 o ThreadGroup(Runnable, String)
Allocates a new ThreadGroup object.
 o ThreadGroup(String)
Allocates a new ThreadGroup object.

Method Index

 o myTeam()
Returns a reference to the currently executing threadgroup object.
 o destroy()
Destroys this threadgroup, without any cleanup.
 o getName()
Returns this threadgroup's name.
 o getPriority()
Returns this threadgroup's priority.
 o interrupt()
Interrupts this threadgroup.
 o interrupted()
Tests if the current threadgroup has been interrupted.
 o isAlive()
Tests if this threadgroup is alive.
 o isDaemon()
Tests if this threadgroup is a daemon threadgroup.
 o isInterrupted()
Tests if the current threadgroup has been interrupted.
 o join()
Waits for this threadgroup to die.
 o join(long)
Waits at most millis milliseconds for this threadgroup to die.
 o join(long, int)
Waits at most millis milliseconds plus nanos nanoseconds for this threadgroup to die.
 o resume()
Resumes a suspended threadgroup.
 o run()
If this threadgroup was constructed using a separate Runnable run object, then that Runnable object's run method is called; otherwise, this method does nothing and returns.
 o setDaemon(boolean)
Marks this threadgroup as either a daemon threadgroup or a user threadgroup.
 o setName(String)
Changes the name of this threadgroup to be equal to the argument name.
 o setPriority(int)
Changes the priority of this threadgroup.
 o sleep(long)
Causes the currently executing threadgroup to sleep (temporarily cease execution) for the specified number of milliseconds.
 o sleep(long, int)
Causes the currently executing threadgroup to sleep (cease execution) for the specified number of milliseconds plus the specified number of nanoseconds.
 o start()
Causes this threadgroup to begin execution; Titanium calls the run method of this threadgroup.
 o stop()
Forces the threadgroup to stop executing.
 o stop(Throwable)
Forces the threadgroup to stop executing.
 o suspend()
Suspends this threadgroup.
 o toString()
Returns a string representation of this threadgroup, including the threadgroup's name, priority, and threadgroup group.
 o yield()
Causes the currently executing threadgroup object to temporarily pause and allow other threadgroups to execute.

Variables

 o MIN_PRIORITY

 public static final int MIN_PRIORITY
The minimum priority that a threadgroup can have.

 o NORM_PRIORITY

 public static final int NORM_PRIORITY
The default priority that is assigned to a threadgroup.

 o MAX_PRIORITY

 public static final int MAX_PRIORITY
The maximum priority that a threadgroup can have.

Constructors

 o ThreadGroup

 public ThreadGroup()
Allocates a new ThreadGroup object. This constructor has the same effect as ThreadGroup(null, null, gname), where gname is a newly generated name. Automatically generated names are of the form "ThreadGroup-"+n, where n is an integer.

ThreadGroups created this way must have overridden their run() method to actually do anything.

See Also:
ThreadGroup

 o ThreadGroup

 public ThreadGroup(Runnable target)
Allocates a new ThreadGroup object. This constructor has the same effect as ThreadGroup(null, target, gname), where gname is a newly generated name. Automatically generated names are of the form "ThreadGroup-"+n, where n is an integer.
Parameters:
target - the object whose run method is called.
See Also:
ThreadGroup

 o ThreadGroup

 public ThreadGroup(String name)
Allocates a new ThreadGroup object. This constructor has the same effect as ThreadGroup(null, null, name).
Parameters:
name - the name of the new threadgroup.
See Also:
ThreadGroup

 o ThreadGroup

 public ThreadGroup(Runnable target,
               String name)
Allocates a new ThreadGroup object so that it has target as its run object, and has the specified name as its name.

If the target argument is not null, the run method of the target is called when this threadgroup is started. If the target argument is null, this threadgroup's run method is called when this threadgroup is started.

The priority of the newly created threadgroup is set equal to the priority of the threadgroup creating it, that is, the currently running threadgroup. The method setPriority may be used to change the priority to a new value.

The newly created threadgroup is initially marked as being a daemon threadgroup if and only if the threadgroup creating it is currently marked as a daemon threadgroup. The method setDaemon may be used to change whether or not a threadgroup is a daemon.

Parameters:
target - the object whose run method is called.
name - the name of the new threadgroup.
See Also:
run, run, setDaemon, setPriority

Methods

 o myTeam

 public static native ThreadGroup myTeam()
Returns a reference to the currently executing threadgroup object.
Returns:
the currently executing threadgroup.

 o yield

 public static native void yield()
Causes the currently executing threadgroup object to temporarily pause and allow other threadgroups to execute.

 o sleep

 public static native void sleep(long millis) throws InterruptedException
Causes the currently executing threadgroup to sleep (temporarily cease execution) for the specified number of milliseconds. The threadgroup does not lose ownership of any monitors.
Parameters:
millis - the length of time to sleep in milliseconds.
Throws: InterruptedException
if another threadgroup has interrupted this threadgroup.
See Also:
notify

 o sleep

 public static void sleep(long millis,
                          int nanos) throws InterruptedException
Causes the currently executing threadgroup to sleep (cease execution) for the specified number of milliseconds plus the specified number of nanoseconds. The threadgroup does not lose ownership of any monitors.
Parameters:
millis - the length of time to sleep in milliseconds.
nanos - 0-999999 additional nanoseconds to sleep.
Throws: IllegalArgumentException
if the value of millis is negative or the value of nanos is not in the range 0-999999.
Throws: InterruptedException
if another threadgroup has interrupted this threadgroup.
See Also:
notify

 o start

 public native synchronized void start()
Causes this threadgroup to begin execution; Titanium calls the run method of this threadgroup.

The result is that two threadgroups are running concurrently: the current threadgroup (which returns from the call to the start method) and the other threadgroup (which executes its run method).

Throws: IllegalThreadGroupStateException
if the threadgroup was already started.
See Also:
run, stop

 o run

 public void run()
If this threadgroup was constructed using a separate Runnable run object, then that Runnable object's run method is called; otherwise, this method does nothing and returns.

Subclasses of ThreadGroup should override this method.

See Also:
start, stop, ThreadGroup, run

 o stop

 public final void stop()
Forces the threadgroup to stop executing.

The threadgroup represented by this threadgroup is forced to stop whatever it is doing abnormally and to throw a newly created ThreadDeath object as an exception.

It is permitted to stop a threadgroup that has not yet been started. If the threadgroup is eventually started, it immediately terminates.

An application should not normally try to catch ThreadDeath unless it must do some extraordinary cleanup operation (note that the throwing of ThreadDeath causes finally clauses of try statements to be executed before the threadgroup officially dies). If a catch clause catches a ThreadDeath object, it is important to rethrow the object so that the threadgroup actually dies.

The top-level error handler that reacts to otherwise uncaught exceptions does not print out a message or otherwise notify the application if the uncaught exception is an instance of ThreadDeath.

See Also:
run, start, ThreadDeath, uncaughtException

 o stop

 public final synchronized void stop(Throwable o)
Forces the threadgroup to stop executing.

If the argument obj is null, a NullPointerException is thrown (in the current threadgroup).

The threadgroup represented by this threadgroup is forced to complete whatever it is doing abnormally and to throw the Throwable object obj as an exception. This is an unusual action to take; normally, the stop method that takes no arguments should be used.

It is permitted to stop a threadgroup that has not yet been started. If the threadgroup is eventually started, it immediately terminates.

Parameters:
obj - the Throwable object to be thrown.
See Also:
checkAccess, run, start, stop

 o interrupt

 public void interrupt()
Interrupts this threadgroup.

 o interrupted

 public static boolean interrupted()
Tests if the current threadgroup has been interrupted. Note that interrupted is a static method, while isInterrupted is called on the current ThreadGroup instance.
Returns:
true if the current threadgroup has been interrupted; false otherwise.
See Also:
isInterrupted

 o isInterrupted

 public boolean isInterrupted()
Tests if the current threadgroup has been interrupted. Note that isInterrupted is called on the current ThreadGroup instance; by contrast, interrupted is a static method.
Returns:
true if this threadgroup has been interrupted; false otherwise.
See Also:
interrupted

 o isAlive

 public final native boolean isAlive()
Tests if this threadgroup is alive. A threadgroup is alive if it has been started and has not yet died.
Returns:
true if this threadgroup is alive; false otherwise.

 o suspend

 public final void suspend()
Suspends this threadgroup.

If the threadgroup is alive, it is suspended and makes no further progress unless and until it is resumed.

See Also:
isAlive

 o resume

 public final void resume()
Resumes a suspended threadgroup.

If the threadgroup is alive but suspended, it is resumed and is permitted to make progress in its execution.

See Also:
isAlive

 o setPriority

 public final void setPriority(int newPriority)
Changes the priority of this threadgroup.

Otherwise, the priority of this threadgroup is set to the smaller of the specified newPriority and the maximum permitted priority of the threadgroup's threadgroup group.

Throws: IllegalArgumentException
If the priority is not in the range MIN_PRIORITY to MAX_PRIORITY.
See Also:
getPriority, getThreadGroupGroup, MAX_PRIORITY, MIN_PRIORITY, getMaxPriority

 o getPriority

 public final int getPriority()
Returns this threadgroup's priority.
Returns:
this threadgroup's name.
See Also:
setPriority

 o setName

 public final void setName(String name)
Changes the name of this threadgroup to be equal to the argument name.

 

Parameters:
name - the new name for this threadgroup.
See Also:
checkAccess, getName

 o getName

 public final String getName()
Returns this threadgroup's name.
Returns:
this threadgroup's name.
See Also:
setName

 o join

 public final synchronized void join(long millis) throws InterruptedException
Waits at most millis milliseconds for this threadgroup to die. A timeout of 0 means to wait forever.
Parameters:
millis - the time to wait in milliseconds.
Throws: InterruptedException
if another threadgroup has interrupted the current threadgroup.

 o join

 public final synchronized void join(long millis,
                                     int nanos) throws InterruptedException
Waits at most millis milliseconds plus nanos nanoseconds for this threadgroup to die.
Parameters:
millis - the time to wait in milliseconds.
nanos - 0-999999 additional nanoseconds to wait.
Throws: IllegalArgumentException
if the value of millis is negative the value of nanos is not in the range 0-999999.
Throws: InterruptedException
if another threadgroup has interrupted the current threadgroup.

 o join

 public final void join() throws InterruptedException
Waits for this threadgroup to die.
Throws: InterruptedException
if another threadgroup has interrupted the current threadgroup.

 o setDaemon

 public final void setDaemon(boolean on)
Marks this threadgroup as either a daemon threadgroup or a user threadgroup. The Java Virtual Machine exits when the only threadgroups running are all daemon threadgroups.

This method must be called before the threadgroup is started.

Parameters:
on - if true, marks this threadgroup as a daemon threadgroup.
Throws: IllegalThreadGroupStateException
if this threadgroup is active.
See Also:
isDaemon

 o isDaemon

 public final boolean isDaemon()
Tests if this threadgroup is a daemon threadgroup.
Returns:
true if this threadgroup is a daemon threadgroup; false otherwise.
See Also:
setDaemon

 o toString

 public String toString()
Returns a string representation of this threadgroup, including the threadgroup's name, priority, and threadgroup group.
Returns:
a string representation of this threadgroup.
Overrides:
toString in class Object