Java Threading Question and Answers
9. | What is the difference in using runnable and extends in threads? |
---|---|
|
|
10. | What is wait() and notify()? |
---|---|
|
|
11. | Can you explain Thread.sleep? |
---|---|
Thread.sleep() is a static method of the Thread class that causes the currently executing thread to delay for a specified number of milliseconds. Below is the code snippet: try { Thread.sleep ( 1000); } Catch ( InterruptedException e) {} |
|
12. | How can one thread wait for another thread to die before it continues execution? |
---|---|
The thread’s join() method allows you to wait for another thread to finish execution. | |