I have a question, I am always asked this in the interviews multiple times--
How is synchronization implemented in ja开发者_StackOverflowva.. I have answered-- using trylock() mechanism using wait, notify ,and notifyAll() methods in java using synchronized blocks using synchronized for class and object level using mutexes for synchronization using re-entrant locks
Are there any better answers to this?/
If you care about gaining a deep insight on concurrency then a great source is the http://www.javaconcurrencyinpractice.com/ book.
If you simply care about "passing" this question in interview(s?) then http://download.oracle.com/javase/tutorial/essential/concurrency/index.html may do, but still you generally need to practice a bit to understand synchronization so you are in a position where you'll sufficiently answer questions following the extremely vague "How is synchronization implemented in java".
Why not read up on Sun's/Oracle's tutorial on Java synchronization? That's the official view.
I'd probably go with something along the lines of what is found here: http://download.oracle.com/javase/tutorial/essential/concurrency/locksync.html
精彩评论