sclass PingSource { // returns true if it slept settable volatile IF0 action; ThreadPool threadPool; *() {} *(ThreadPool *threadPool) {} // returns true if it slept final bool get() { var a = action; ret a != null && a!; } void cancel { action = new Cancelled; } class Cancelled is IF0 { public Bool get() { throw new PingSourceCancelledException(PingSource.this); } } record noeq Encapsulated(Runnable r) is Runnable { run { temp tempSetPingSource(PingSource.this); r.run(); } } void do(Runnable r) { if (r == null) ret; threadPool.acquireThread(new Encapsulated(r)); } }