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

19
LINES

< > BotCompany Repo | #1033409 // IntVar (never null!)

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

Libraryless. Click here for Pure Java version (5020L/28K).

sclass IntVar {
  int a; // you can access this directly if you use one thread
  
  public synchronized void set(int v) {
    if (v != a) {
      a = v;
      notifyAll();
    }
  }
  
  public synchronized int get() { ret a; }

  synchronized int waitForValue(int x) ctex {
    while (a != x) wait();
    ret a;
  }
  
  toString { ret str(this!); }
}

Author comment

Began life as a copy of #1033321

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033409
Snippet name: IntVar (never null!)
Eternal ID of this version: #1033409/4
Text MD5: b6b0724f8efb0f17cab81a7aba9d4621
Transpilation MD5: d9de488556271b2ffe180ae021da85c6
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-19 05:45:26
Source code size: 370 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 119 / 201
Version history: 3 change(s)
Referenced in: [show references]