Blogger

Delete comment from: Javarevisited

subuhi said...

1) Why one has to use volatile var in multithreaded environment .
Can't same task be achieved by using static var ?
because in static var all threads would see the latest written value of that var .

and static var would be one per class and hence one instance of that var will be shared among threads .


2) Why ThreadLocal was introduced in java , when the motive is to provide each thread its own local copy , can't normal instance variables do the same by default ?

Oct 31, 2015, 12:12:10 PM


Posted to Top 133 Java Interview Questions Answers for 2 to 5 Years Experienced Programmers

Google apps
Main menu