Libraryless. Click here for Pure Java version (5020L/28K).
1 | sclass IntVar {
|
2 | int a; // you can access this directly if you use one thread |
3 | |
4 | public synchronized void set(int v) {
|
5 | if (v != a) {
|
6 | a = v; |
7 | notifyAll(); |
8 | } |
9 | } |
10 | |
11 | public synchronized int get() { ret a; }
|
12 | |
13 | synchronized int waitForValue(int x) ctex {
|
14 | while (a != x) wait(); |
15 | ret a; |
16 | } |
17 | |
18 | toString { ret str(this!); }
|
19 | } |
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: | 492 / 654 |
| Version history: | 3 change(s) |
| Referenced in: | [show references] |