Intuit Interview Question
Senior Software Development EngineersCountry: United States
1) Join()=> the current thread has to wait for the thread's object exit status.
2) wait()=> wait() tells the calling thread to give up the monitor and go to sleep until some other thread enters the same monitor and calls notify( ).
3) Sleep()=> it hold the current thread execution.
Wait() releases the lock() of the moniter
1) Join(): this method waits for a thread to die. for example:
Here, at first t1 thread completes it execution then the t2 and t3 starts there execution.
2) wait(): when this method is called that means it waits for a thread to be completed. Normally this method is used where there is needed synchronize execution. for example:
In the above code, when b thread finishes its operation then it calls the notify() method. Then the wait() method terminates the waiting.
- Md. Mahedi Kaysar September 25, 2014If you conceptually want to understand, then you can consider the producer and consumer problem where consumer waits for a product to be produced by the producer. That means, when producer notify the consumers only then the consumers can consume the products.
3) sleep(ms): Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds.