Java Threading Question and Answers
13. | What is the relationship between a synchronized and volatile keyword? |
---|---|
|
|
14. | What are the ways in which a thread can enter the waiting state? |
---|---|
|
|
15. | What invokes a thread’s run() method? |
---|---|
After a thread is started, via its start() method of the Thread class, the JVM invokes the thread's run() method when the thread is initially executed. | |
16. | What are the different ways of creating thread? |
---|---|
Implementing Runnable: The Runnable interface defines a single method, run, meant to contain the code executed in the thread. Subclass Thread: The Thread class itself implements Runnable interface, though it runs method does nothing. |
|