Java Creating Instance of BufferedImage Freezes Pr

2019-06-01 02:13发布

问题:

I'm experiencing something really strange, and I don't know what's causing it at all. This is the problematic line of code:

BufferedImage out = new BufferedImage(256, 256, BufferedImage.TYPE_INT_RGB);

Upon calling this, all threads freeze and everything stops. I've tried putting this in its own thread and the main thread, the same thing occurs. I am using LWJGL3, so that might be an issue, but I don't see how it could be.

Edit: Does not occur in a blank project without LWJGL in or out of -XstartOnFirstThread

回答1:

Ok! I found the solution. Turns out, all it takes is the following JVM argument: -Djava.awt.headless=true You also have to make sure that you aren't running it in the main thread, you have to do it outside of the thread where GLFW is initialized.

All of this only applies if you are running LWJGL on Mac, Linux and Windows don't have this issue.