Академический Документы
Профессиональный Документы
Культура Документы
Threads vs. Processes Thread Creation by Implementing Runnable Creating Threads by Subclassing Advantages of using Threads Thread States Using join() Synchronization wait() and notify()
(V. 2001.02.a)
Slide 1
(V. 2001.02.a)
Slide 2
(V. 2001.02.a)
Slide 5
(V. 2001.02.a)
Slide 7
Thread States
A thread can be in various states during its lifetime: new runnable blocked dead Various thread methods control the state in which the thread exists. We have seen a few of these methods such as run() and start() methods. Other methods of the Thread class are: public statis void yield() causes the currently executing thread object to tempoarily pause and allow other threads to execute. public final void setPriority(int newpr) sets the priority of this thread to the new priority newpr public static void sleep(long millis) throws InterruptedException causes the currently executing thread to sleep for the specified number of milliseconds public static Thread currentThread() returns a reference to the currently executing thread object
Mathis Introduction to Java (V. 2001.02.a) Slide 8
Thread States
public final String getName() returns this threads name public final void join() throws Interrupted Exception waits for this thread to die public final boolean is Alive() tests if this thread is alive; a thread is alive if it has been started and has not yet died
(V. 2001.02.a)
Slide 9