// Note: Costs one thread while it exists sclass RunnablesReferenceQueue is AutoCloseable { new ReferenceQueue queue; volatile Thread thread; new Flag closed; settable int timeout = 60000; // just for safety *() { thread = startThread("RunnablesReferenceQueue", l0 _run); } void _run() ctex { try { while (ping() && !closed!) { Reference ref = queue.remove(timeout); if (ref != null) { if (ref cast Runnable) pcallF(ref); else warn("RunnablesReferenceQueue: Reference not runnable - " + className(ref)); } } } catch InterruptedException e { } finally { thread = null; } } close { closed.raise(); interruptThread(thread); } ReferenceQueue queue aka get() { ret queue; } }