Hello,


So I know the difference between getLong and getLongVolatile => visibility. 
By using getLongVolatile I avoid any thread/process cache and I can be sure 
to read the latest contents from memory. Great! But how about 
synchronization / atomicity? *Do any of these two methods (getLong and 
getLongVolatile) will protect me from a writer in another process writing 
my 8 bytes while I'm reading them?*


>From practical experience using this, I would think so, but just wanted to 
run that question through you guys to see what you have to say about that. 
Perhaps only if the writer is also using putLong and putLongVolatile? What 
about if the writer is writing byte by byte with putByte or 
putByteVolatile? Would this situation cause a race-condition between reader 
and writer?


And a bonus questions:


How such synchronization / atomicity would be implemented at the C level by 
Unsafe? Is the C source code of Unsafe available somewhere so we can take a 
look to find out?


-Fred




-- 
You received this message because you are subscribed to the Google Groups 
"mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/mechanical-sympathy/0b8a3784-5df3-4648-9d3c-918ab4694564n%40googlegroups.com.

Reply via email to