static class Q2 implements AutoCloseable { S name = "Unnamed Queue"; L q = synchroLinkedList(); ReliableSingleThread rst = new(r { _run() }); volatile bool retired; *() {} *(S *name) {} void add(Runnable r) { q.add(r); rst.go(); } void add(O r) { add(toRunnable(r)); } void _run() { L l = cloneAndClearList(q); for (Runnable r : l) { if (!licensed() || retired) ret; pcall { r.run(); } } } public void close() { retired = true; } // TODO: interrupt thread bool isEmpty() { ret q.isEmpty(); } }