Download Jar. Libraryless. Click here for Pure Java version (7260L/50K).
!7 // apparently this is the correct way to do double-checked locking sclass A {} static volatile A lazy; static A getA() { A tmp = lazy; /* Minimize slow accesses to `volatile` member. */ if (tmp == null) { synchronized (mc()) { tmp = lazy; if (tmp == null) lazy = tmp = new A; } } ret tmp; } p-exp { print(getA()); print(getA()); }
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1029155 |
Snippet name: | Double Checked Locking Example |
Eternal ID of this version: | #1029155/2 |
Text MD5: | bc6879c7074bea57a6e40960c903a8da |
Transpilation MD5: | 5121d55d5ff9ede9d7edf69bd7edb837 |
Author: | stefan |
Category: | javax / html |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-07-22 02:38:40 |
Source code size: | 402 bytes / 24 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 258 / 869 |
Version history: | 1 change(s) |
Referenced in: | -