Today's Question:  What weekend projects have you created?        GIVE A SHOUT

Technical Article => Programming =>  Java

Multithreading interview questions in Java

  Peter      2012-05-28 06:33:25      22,391    3

Multithreading as a widespread programming and execution model allows multiple threads to exist within the context of a single process. These threads share the process' resources but are able to execute independently. The threaded programming model provides developers with a useful abstraction of concurrent execution. However, perhaps the most interesting application of the technology is when it is applied to a single process to enable parallel execution on a multiprocessor system.

Many programmers don't know how to use multithreading correctly, and we often get some advice from people regarding use of multithreading: Don't use multithreading or at least limit use of multithreading. But sometimes it's better to use multithreading when we want to give users better user experience, for example in GUI programming or some long running process. Then we need to understand some details about multithreading. Also, many interview questions are from multithreading.

summarized a list of Java multithreading interview questions. He gave the answers to these questions. Hope this can help those who want to understand multithreading or who are preparing for interviews.

These are the some of question:
  1. What is synchronization in respect to multi-threading in Java?
  2. Explain different way of using thread?
  3. What is the difference between Thread.start() & method?
  4. Why do we need run() & start() method both. Can we achieve it with only run method?
  5. What is ThreadLocal class? How can it be used?
  6. When InvalidMonitorStateException is thrown? Why?
  7. What is the difference between sleep(), suspend() and wait() ?
  8. What happens when I make a static method as synchronized?
  9. Can a thread call a non-synchronized instance method of an Object when a synchronized method is being executed ?
  10. Can two threads call two different synchronized instance methods of an Object?

For the full list of questions and answers, please go to 20 Multi Threading Interview Questions & Answers for Java Developers



Share on Facebook  Share on Twitter  Share on Google+  Share on Weibo  Share on Reddit  Share on Digg  Share on Tumblr    Delicious



Javin [Reply]@ 2012-05-30 09:03:30
I already read that article, nice one, thanks for re posting. you may also like these 15 Java threading and concurrency questions
Javin [Reply]@ 2012-05-30 09:04:40
Sachin [Reply]@ 2012-05-31 00:52:28
Thanks for the mention, just stopped by to say thanks for the mention.


Make a feint to the east but in the west

By sonic0002