criticalSection
Executes block while this AtomicBoolean is set to true, then restores the value it had before.
This is useful for signaling that a critical section is in progress. Restoring the previous value, rather than storing false, keeps the flag set for an outer section when sections nest. It is still one flag, not a lock or a count: when two threads overlap, the first to finish restores the value it saw, so the flag cannot say whether the other is still inside. Use a counter or a lock for that.
Return
the result of block
Parameters
block
the code to execute within the critical section
Type Parameters
T
the return type of the block