Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

21
LINES

< > BotCompany Repo | #1032845 // Var [Include without toString]

JavaX fragment (include) [tags: use-pretranspiled]

A v; // you can access this directly if you use one thread

public synchronized void set(A a) {
  if (v != a) {
    v = a;
    notifyAll();
  }
}

public synchronized A get() { ret v; }
public synchronized bool has() { ret v != null; }
public void clear() { set(null); }

public synchronized A getAndSet(A a) {
  var value = v;
  set(a);
  ret value;
}

public IF0<A> getter() { ret l0 get; }
public IVF1<A> setter() { ret l1 set; }

Author comment

Began life as a copy of #1023196

download  show line numbers  debug dex  old transpilations   

Travelled to 9 computer(s): bhatertpkbcr, dpqxeycirhfy, ekrmjmnbrukm, elmgxqgtpvxh, mowyntqkapby, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, wnsclhtenguj

No comments. add comment

Snippet ID: #1032845
Snippet name: Var [Include without toString]
Eternal ID of this version: #1032845/9
Text MD5: 798334d0cba6305050a9e11b2f6230a8
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-06-27 02:44:26
Source code size: 452 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 57 / 12606
Version history: 8 change(s)
Referenced in: [show references]