Tuesday, November 29, 2011

How to make application thread-safe ?

You should use the word synchronized to mark the critical section of code. You may also use other methods of thread synchronization (see wait(), notify(), notifyAll() etc.:Using synchronized keyword you can make thread safe application and you can also use wait(), notify(), notifyall(). All these methods are of Object class.:You can also use the ReentrntLock class which implements Lock interface. It has three methods signal(), signalAll() and await() methods for synchronization. This was introduced in JDK 5.:We can implement the interface as SingleThreadModel.:It really not something which can be answered directly without looking at the application which you want to make thread safe. As a matter of fact to make a program thread safe all you need to do is make sure you don&
Category:Java Interview Questions

No comments:

Post a Comment