Search your topic in Java2share
Home > FAQs
eXTReMe Tracker

Multi Threading FAQs

Untitled Document

Q37. What is the advantage of synchronized block over synchronized method?
Ans.   If very few lines of the code required synchronization then declaring entire method as the synchronized is not recommended. We have to declare those few lines of the code inside synchronized block. This approach reduces waiting time of the Thread and improves performance of the system.

Q38.  What is synchronized statement?
Ans.   The Statement which is inside the synchronized area (synchronized method or synchronized block) is called synchronized statement.

Q39.  How we can declare synchronized block to get class level lock?
Ans.   To get the class level lock we can declare synchronized block as follows:

Q40.   How two thread will communicate with each other?
Ans.    Two Threads will communicate with each other by using wait(), notify(), notifyAll() methods.