Transpiled version (5752L) is out of date.
1 | svoid test_ThreadPool() { |
2 | new ThreadPool pool; |
3 | print(pool); |
4 | flagTest(flag -> pool.acquireThread((Runnable) flag), 10.0); |
5 | print(pool); |
6 | |
7 | int n = pool.maxSize()*2; |
8 | new IntVar counter; |
9 | new IntVar waitCounter; |
10 | pool.onCustomerMustWaitAlert(-> inc(waitCounter)); |
11 | for immutable i to n: { |
12 | var t = pool.acquireThread(r { |
13 | sleepSeconds((i+1)*0.2); |
14 | printWithMS(this + " done"); |
15 | inc(counter); |
16 | }); |
17 | printWithMS("Acquired thread " + t); |
18 | } |
19 | counter.waitForValue(n); |
20 | assertEquals(4, waitCounter!); |
21 | print(pool); |
22 | } |
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033408 |
Snippet name: | test_ThreadPool (OK) |
Eternal ID of this version: | #1033408/9 |
Text MD5: | 41632b3a210b7a1a7e2b57536e8025f8 |
Author: | stefan |
Category: | javax / code execution |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-11-02 02:04:36 |
Source code size: | 571 bytes / 22 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 174 / 252 |
Version history: | 8 change(s) |
Referenced in: | [show references] |