srecord noeq FastCollabWorker(FastCollab collab, int workerIndex) extends Thread { volatile gettable long errorCount; volatile gettable long spinWaits; volatile gettable long workCount; volatile gettable Throwable lastError; settable PingSource interruptor; int sleepTime; run { Runnable work; var interruptor = this.interruptor; sleepTime = collab.sleepTime; while ((work = collab.grabWork(workerIndex)) != collab.DONE) { interruptor?.ping(); try { if (work != null) { ++workCount; work.run(); } else waitSome(); } catch e { ++errorCount; lastError = e; } } } void waitSome ctex { if (sleepTime == 0) ++spinWaits; else sleep(sleepTime); } }