Java 5 uses atomic object (Lock) to provide alternative to synchronization. Lock is nothing but the hardware level constructs of CAS. What is some processors do not support CAS and I have code with Lock object being used in it?
I think it will break. Any idea? [ April 14, 2008: Message edited by: Kartik Patel ]
Chop your own wood, and it will warm you twice. - Henry Ford
chatchai chailuecha
Greenhorn
Joined: Dec 14, 2006
Posts: 18
posted
0
In "Java concurrency in practice" by Brian goetz
15.2.3. CAS Support in the JVM On platforms supporting CAS, the runtime inlines them into the appropriate machine instruction(s); in the worst case, if a CAS-like instruction is not available the JVM uses a spin lock.
The javadoc about compareAndSet operation states that:
The specifications of these methods enable implementations to employ efficient machine-level atomic instructions that are available on contemporary processors. However on some platforms, support may entail some form of internal locking. Thus the methods are not strictly guaranteed to be non-blocking
I guess the spin lock will be used instead
[ April 14, 2008: Message edited by: chatchai chailuecha ]
[ April 14, 2008: Message edited by: chatchai chailuecha ] [ April 14, 2008: Message edited by: chatchai chailuecha ]
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.