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.

- 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 the current thread.

- The join() allows you to specify a maximum amount of time which you want to wait for the specified thread to terminate.
Explain the purpose of yield method.
Explain the purpose of yield method - Yield method causes the currently executing thread object to temporarily pause and allow other threads to execute....
What is the difference between yielding and sleeping?
What is the difference between yielding and sleeping? - Sleep holds the threads execution for the specified time. On the other hand, yield will cause the thread to rejoin the queue....
What is a task's priority and how is it used in scheduling?
What is a task's priority and how is it used in scheduling? - A scheduler uses the priorities of a task to determine its execution. Priorities can be high or low determined.....
Post your comment