Will the emitting variable be changed? The emit() method is called from different threads, and the radiation should be visible.
But it is only available in synchronized blocks. // ... are places where work is done, but emitting is not mentioned here.
So, if the synchronized structure is fixed, do I still need volatile for emitting or not? (and why?)
static final class C { boolean emitting = false; // shall be volatile ? public void emit() { synchronized (this) { if (emitting) { return; } // ... emitting = true; } // ... synchronized (this) { if (!condition()) { emitting = false; return; } } // ... }
Franc
source share