|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ochafik.lang.Threads
public final class Threads
Group of coordinated Runnable instances that can be started, interrupted and waited for together.
Once you added as many runnable tasks as needed through the add(Runnable) method, there are two ways of waiting for the tasks to finish :
Nested Class Summary | |
---|---|
static class |
Threads.State
|
Constructor Summary | |
---|---|
Threads()
|
Method Summary | ||
---|---|---|
|
add(T runnable)
Add a task that is to be executed in its own thread. |
|
void |
addActionListener(ActionListener actionListener)
Adds a listener that will be notified upon completion of all of the running threads. |
|
Threads.State |
getState()
|
|
void |
interrupt()
Calls interrupt() on each of the running threads. |
|
void |
join()
Waits for all runnable to have finished their execution. |
|
void |
start()
Starts all the threads. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Threads()
Method Detail |
---|
public <T extends Runnable> T add(T runnable)
runnable
- task to be executed in its own thread
public void start()
IllegalThreadStateException
- if the threads were already started.
NoSuchElementException
- if no runnable were added to this Threads instance.public void interrupt()
IllegalThreadStateException
- if threads were not startedpublic void join() throws InterruptedException
InterruptedException
- if method interrupt() was called on the thread that is calling this method.public Threads.State getState()
public void addActionListener(ActionListener actionListener)
actionListener
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |