Libraryless. Click here for Pure Java version (4566L/25K).
1 | sclass WeakVar<A> implements IVar<A> { |
2 | WeakReference<A> ref; |
3 | |
4 | public synchronized void set(A a) { |
5 | ref = weakRef(a); |
6 | } |
7 | |
8 | public synchronized A get() { |
9 | if (ref == null) null; |
10 | A value = ref!; |
11 | if (value == null) ref = null; |
12 | ret value; |
13 | } |
14 | } |
Began life as a copy of #1033409
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033721 |
Snippet name: | WeakVar - Var using a weak reference |
Eternal ID of this version: | #1033721/3 |
Text MD5: | 6af7f86cc5cf92d8052195bcd73344ba |
Transpilation MD5: | 9faad8f53f71bdac7b4a6bebb34fce56 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-12-28 22:00:08 |
Source code size: | 280 bytes / 14 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 190 / 300 |
Version history: | 2 change(s) |
Referenced in: | [show references] |