AtomicXXX usage

I'm reading the JME3 code because of a weird issue (LWJGL thread in a permanent sleep state). I haven't tracked down the source of the problem yet but, in the meantime…



The jme3 code uses Atomic wrappers.

AtomicXYZ  fields need to be final or accessed through synchronized statements because the field itself is not covered by the "as if volatile" semantic of atomic wrappers.



There is also a problem with the constructor of LWJGLCanvas as it exposes "this" during initialization. I have to say that I'm not sure if in the context of LwjglCanvas this is an actual problem because what really makes the exposure of "this" unsafe is an access to a partially initialized instance by a different thread and I don't see this access happening in the code as it is but if you see it than you have to take a different approach.

pgi said:

I'm reading the JME3 code because of a weird issue (LWJGL thread in a permanent sleep state)


Got it, i had to set application.pauseOnFocus to false.

So the atomic usage is fine? I don't think I ever saw any code use synchronized() on those, I thought those classes were supposed to handle it efficiently inside.