Saturday, February 22, 2020

Top 10 questiosn in Thread


-------------------------------------
One of my room mate have been preparing for java interview from past few days.
1) Since start() method of Thread class eventually calls run() method ? why should we not directly call run() method ?

2) I have two  separate threads running separate task but I want them to run in a specic order ? how can I acheive this ?

3) What will happen if I call start() method on a running thread ?

4) What is the difference between sleep() and wait() method ?

5) What are the ways you can stop Thread ?

6) How do you find if a thread holds a lock or not ?

7) What is deadlock and how will you fix this ?

8) What is the difference between interuppted() and isInteruppted() ?

9) How do you acheive thread intercommunication ?

10) What is volatile modifier ?

No comments:

Post a Comment

Feel free to comment, ask questions if you have any doubt.