ouch, this bug was commited to tiger, which is still a year or so off. i guess that means it can't be fixed with the current api/spec without breaking something else.
ironically, the deadlock fix i posted here actually
creates a deadlock on Mac OS X's java 1.4.1_01. good times.
so, here's another workaround that's cross platform (at least on the mac and windows machines i tested) and makes a little more sense based on what the problem is.
call createBufferStrategy in the awt event dispatch thread:
1 2 3 4 5 6 7 8 9 10 11 12
| device.setFullScreenWindow(frame); if (displayMode != null && device.isDisplayChangeSupported()) { try { device.setDisplayMode(displayMode); } catch (IllegalArgumentException ex) { } } EventQueue.invokeAndWait(new Runnable() { public void run() { frame.createBufferStrategy(2); } }); |
this will make sure createBufferStrategy can't deadlock with the event dispatch thread, since it's now run in the same thread.