whenSynchronized method
Implementation
void whenSynchronized(ExecuteWhenSynchronized execute) {
if (isSynchronized) {
execute(); // Execute immediately if already synchronized.
} else {
executeWhenSynchronized
.add(execute); // Otherwise, add it to the queue for later execution.
}
}