ThreadLocal in Java is another way to achieve thread-safety apart from writing immutable classes. If you have been writing multi-t..
| Home | My Account | Directories |
How to use ThreadLocal in Java - Benefits, Example Tutorial
Published on 2012-05-30 10:17:00
ThreadLocal in Java is another way to achieve thread-safety apart from writing immutable classes. If you have been writing multi-threaded or concurrent code in Java then you must be familiar with cost of synchronization or locking which can greatly affect Scalability of application, but there is no choice other than synchronize if you are sharing objects between multiple threads. ThreadLocal in Java is a different way to achieve thread-safety, it doesn't address synchronization requirement, instead it eliminates sharing by providing explicitly copy of Object to each thread. Since Object is no more shared there is no requirement of Synchronization which can improve scalability and performance of application. In this Java ThreadLocal tutorial we will see important points about ThreadLocal in Java, when to use ThreadLocal in Java and a simple Example of ThreadLocal in Java program.Read more ยป Java, Unix, Tibco RV and FIX Protocol Tutorial
read more: How to use ThreadLocal in Java - Benefits, Example Tutorial