문제

Does anyone know of any comprehensive documentation for sun.misc.Unsafe?

I'm looking for documentation on Unsafe.putOrderedInt(). This was all I was able to find.

public native  void putOrderedInt(Object o,
    long offset,
    int x)

     Ordered/Lazy version of #putIntVolatile(Object, long, int) 

Does anyone know of a better source?

도움이 되었습니까?

해결책

There is a nice post about it on mishadoff's blog here.

The class is officially undocumented though.

다른 팁

Regarding the putOrdered methods..

You can call this method to set the volatile field without using a volatile store.. If you execute a volatile store, you basically have a store memory barrier which ensures that all store instruction prior the barrier, happen before barrier and that memory is visible by ensuring the data is propagated to the cache sub-system.. So when you have the volatile store you must wait for the store buffer to drain.. With putOrdered thread executing will not wait for the store buffer to drain and this can improve performance.. However as a consequence stored value will not be visible to other threads immediately..

If you have a look on AtomicLong (or other Atomic classes) there is a lazySet method that actually executes putOrderedLong. The javadoc on this method is:

Eventually sets to the given value.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top