Unsafe类功能之(6)-内存屏障-fence

  1. loadFence
  2. storeFence
  3. fullFence

loadFence

loadFence() 表示该方法之前的所有load操作在内存屏障之前完成。
(Ensures lack of reordering of loads before the fence with loads or stores after the fence.)

public native void loadFence();

storeFence

storeFence()表示该方法之前的所有store操作在内存屏障之前完成。
(Ensures lack of reordering of stores before the fence with loads or stores after the fence.)

public native void storeFence();

fullFence

fullFence()表示该方法之前的所有load、store操作在内存屏障之前完成。
(Ensures lack of reordering of loads or stores before the fence with loads or stores after the fence.)

public native void fullFence();

转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 hi@niewj.com

×

喜欢就点赞,疼爱就打赏