You can read this topic, I had issues with this as well:
The only safe synchronization between the main thread and the OpenGL thread that cannot deadlock is using setComponentPaintingEnabled(true), in which case the MessageManagerLock is acquired for you. Everything else is a potential deadlock, unfortunately.