Shutdown Future deadlock?

I was reading some threads about how to cleanly shut down StandardGame and came upon some interesting discussions. Two of those were the following:

*http://www.jmonkeyengine.com/forum/index.php?topic=11008.0

*http://www.jmonkeyengine.com/forum/index.php?topic=8310.15



I haven’t yet had any problems with shutting StandardGame down cleanly, I can use the cleanup() method to clean up the GameState’s, but it’s the problem with Future’s that interests me.

Isn’t it still possible for StandardGame to get a deadlock if the OpenGL thread closes and a .get() is waiting for a Future, like is described in those threads?

Perhaps someone who is more experienced in concurrency can enlighten me?

Is the preferred way to avoid this problem to make use of the classes listed in the first topic above?



Thank you!

Well I usually use just System.exit(0)

and rely on the VM/Os to clean up without any problems so far.

So if you use System.exit(0) in a cleanup() method of one of your game states (in the last one left, rather), e.g. in the event that the user clicks the X on the window, that would interrupt any task threads in the GameTaskQueue waiting for a Future?

well it basically garbace collects everything and frees the memory, then it selfkills.

To be true I don't know about the opengl stuff, but i assuem that the drivers unload all crap if the context is killed

At least i never had any strang problems with that