sclass Fiber { Thread runningInThread; long grabCount; final Map fiberLocalValues = syncWeakMap(); synchronized void grab { Thread t = currentThread(); if (runningInThread != null && runningInThread != t) failWithVars("Trying to assign virtual thread to 2 threads", +thread1 := runningInThread, thread2 := t); runningInThread = t; grabCount++; } synchronized void release { Thread t = currentThread(); if (runningInThread != t) failWithVars("Broken release", +thread1 := runningInThread, thread2 := t); if (--grabCount == 0) runningInThread = null; } O getFiberLocalValue(IVar fiberLocal) { ret fiberLocalValues.get(fiberLocal); } void setFiberLocalValue(IVar fiberLocal, O value) { fiberLocalValues.put(fiberLocal, value); } void foretFiberLocalValue(IVar fiberLocal) { fiberLocalValues.remove(fiberLocal); } }