Java Creating Instance of BufferedImage Freezes Program

随声附和 提交于 2019-12-08 03:22:12

问题


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.



来源:https://stackoverflow.com/questions/44379870/java-creating-instance-of-bufferedimage-freezes-program

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!