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
Joined: Dec 14, 2006
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 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 ]