Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why are CAS (Atomic) operations faster than synchronized or volatile operations

Status
Not open for further replies.

salils

Programmer
Mar 11, 2002
12
US
From what I understand, synchronized keyword syncs local thread cache with main memory. volatile keyword basically always reads the variable from the main memory at every access. Of course accessing main memory is much more expensive than local thread cache so these operations are expensive. However, a CAS operation use low level hardware operations but still has to access main memory. So how is a CAS operation any faster?

Thanks,
Salil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top