This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes synchronized vs ReentryReadWriteLock Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "synchronized vs ReentryReadWriteLock" Watch "synchronized vs ReentryReadWriteLock" New topic

synchronized vs ReentryReadWriteLock

Helen Ma
Ranch Hand

Joined: Nov 01, 2011
Posts: 451
1. sychronized (obj) means aquiring the lock of the object.
2. Consider the lock:

For synchronize keyword, it locks the object.
For lock, it does not lock any object. This lock is an indicator that indicates the code below it is mutal exclusive.
Is this true?
Roel De Nijs

Joined: Jul 19, 2004
Posts: 5123

First of all: ReentryReadWriteLock is an unexisting class in JDK. I guess you meant ReentrantReadWriteLock.

Secondly I think Anayonkar Shivalkar gave an excellent explanation about that part of the new concurrency api in this post.

SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
I agree. Here's the link:
subject: synchronized vs ReentryReadWriteLock
Similar Threads
wait() in synchronized code ??
About Object lock
Creating multiple children threads
Is a monitor the same thing as a lock?
how can i achieve a 100% thread safty method ?