Chapter 24 Flashcards
What will happen if all waiting threads have a lower priority in yield method
It resumes original thread execution
Does yield method used in cooperative scheduling schemes
Yes
How we can handle starvation
- Sleep
- Yield
What sleep do
Sleep method used for delay purpose. It causes the currently executing thread to wait for the time specified and call the second highest priority thread to executive
What is the method for yield
yield()
What is the difference between yield and sleep
Sleep use in latest machines and yield is for old machines where processing is not time sliced. In such machines, a thread keep continuously executes until it ends. So then yield comes in handy. It allows another thread to execute but with same priority level.
One more difference is thread moves first to sleeping state and then ready state in sleep method. But moves direct to ready state from running state in yield method.
What is ready state of thread
A state where thread is ready to execute but not executing
What is running state of thread
A state where thread is executing
Does yield used for pooling
Yes
What are states of threads
- New
- Ready
- Running
- Dead
- Blocked (block because of Input/output)
- Sleep
- Wait
What is wait and notify methods
We can put running thread to wait state by wait method and then it can only be resume by calling notify method.
What is join() method
A thread can wait for another thread just like callback by using join method. It could happen in real time that a running thread require another thread to complete.