com.sibvisions.util
Class ThreadHandler

java.lang.Object
  extended by com.sibvisions.util.ThreadHandler

public final class ThreadHandler
extends java.lang.Object

The ThreadHandler is a utility class for ThreadManager. It is the singleton access to global thread management.


Method Summary
static boolean add(java.lang.Thread pThread)
          Adds a thread to the thread list.
static java.util.List<java.lang.Thread> getPendingStoppedThreads()
          Gets all pending stopped threads which are already alive.
static java.util.List<java.lang.Thread> getRunningThreads()
          Gets all alive threads from the thread list.
static boolean isStopped()
          Gets if the current thread is stopped.
static boolean isStopped(java.lang.Thread pThread)
          Gets if the given thread is stopped.
static void remove(java.lang.Thread pThread)
          Removes a thread from the list.
static java.lang.Thread start(java.lang.Runnable pRunnable)
          Starts a thread and adds it to the thread list.
static void stop()
          Stops/interrupts all threads from the thread list.
static java.lang.Thread stop(java.lang.Thread pThread)
          Stops/interrupts a thread and removes it from the thread list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

add

public static boolean add(java.lang.Thread pThread)
Adds a thread to the thread list.

Parameters:
pThread - the thread
Returns:
true if the thread was added, otherwise false
See Also:
ThreadManager.add(Thread)

remove

public static void remove(java.lang.Thread pThread)
Removes a thread from the list.

Parameters:
pThread - the thread
See Also:
ThreadManager.remove(Thread)

start

public static java.lang.Thread start(java.lang.Runnable pRunnable)
Starts a thread and adds it to the thread list.

Parameters:
pRunnable - a Thread or another Runnable implementation
Returns:
a new Thread with the pRunnable or pRunnable if it's an instance of Thread and the thread is still alive.
See Also:
getRunningThreads(), ThreadManager.start(Runnable)

stop

public static java.lang.Thread stop(java.lang.Thread pThread)
Stops/interrupts a thread and removes it from the thread list.

Parameters:
pThread - the thread, which is to be stopped
Returns:
null
See Also:
getPendingStoppedThreads(), ThreadManager.stop(Thread)

stop

public static void stop()
Stops/interrupts all threads from the thread list.

See Also:
stop(Thread), ThreadManager.stop()

isStopped

public static boolean isStopped()
Gets if the current thread is stopped.

Returns:
true if the current thread is stopped, otherwise false
See Also:
ThreadManager.isStopped()

isStopped

public static boolean isStopped(java.lang.Thread pThread)
Gets if the given thread is stopped.

Parameters:
pThread - the thread
Returns:
true if pThread is stopped or pThread == null, otherwise false
See Also:
ThreadManager.isStopped(Thread)

getPendingStoppedThreads

public static java.util.List<java.lang.Thread> getPendingStoppedThreads()
Gets all pending stopped threads which are already alive.

Returns:
a list of threads
See Also:
ThreadManager.getPendingStoppedThreads()

getRunningThreads

public static java.util.List<java.lang.Thread> getRunningThreads()
Gets all alive threads from the thread list.

Returns:
a list of threads
See Also:
ThreadManager.getRunningThreads()


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.