How do we allow one thread to wait while other to finish?

Explain how do we allow one thread to wait while other to finish.

- The wait() method, notify() method, and notifyAll() method provide an efficient transfer of control from one thread to another.

- A thread can suspend itself using wait() method till a time another thread notifies.

- Thread groups are used to invoke methods which apply to all threads in the group.

- Using the join() method, one can allow one thread to wait while other to finish.

Syntax:
Public final void join()

- An interrupted exception is thrown if another thread has interrupted current thread.
Purpose of yield method
Purpose of yield method - The yield method causes the currently executing thread object to temporarily pause...
Difference between yielding and sleeping
Yielding and sleeping - The sleep() causes the thread to suspend its running only for a specified amount of time, The yield() causes the thread to join the ready queue in the CPU again...
27 Java Multithreading Interview Questions and Answers
Java multithreading interview questions and answers for both freshers and experienced - Process and Thread, Daemon thread, Preemptive scheduling vs. time slicing, max-priority, min-priority and normal-priority level, priority for Garbage collector thread...
Post your comment