Subj : Re: Synchronization constructs in Java and their implications To : comp.programming.threads From : Joe Seigh Date : Mon Sep 26 2005 08:57 am Minkoo Seo wrote: > Hi, all. > > I'm not sure whether this is the already discussed issue or not. > Anyway, searching 'JAVA', 'JAVA spinlock', and 'JAVA reentrantlock' > didn't return any articles seems to be relevant to my question. > > Here's my question. As some of you might already knows, > JDK 5.0 added some new synchronization constructs like > ReentrantLock, Semaphore, and AtomicInteger. Before > them, 'synchronized' was the only keyword available. And it > automatically inserts memory barrier which make it possible to > thread-safe programs in SMP. However, it is not obvious whether > those new constructs are thread safe or not. So, please tell me. > Are those constructs insert memory barriers as the synchronized > keyword does? Yes. They're using a combination of synchronized/notify/wait, the new interlocked atomics, and JSR-133 volatiles which have acquire/release semantics, so everything should be ok in theory. -- Joe Seigh When you get lemons, you make lemonade. When you get hardware, you make software. .