I'm trying to learn how to make games using Java. I moved from C++ to Java in order to 1) focus on learning game-specific software design, 2) place my games online using applets.

I've made a basic applet using LWJGL tutorial (found here). When debugging I've noticed that it takes around 5-10 seconds to end execution once I've closed the applet window. I think this behavior is not from my code since the LWJGL gear example (found here) does the same.

Am I doing something wrong? I feel uncomfortable knowing that maybe I'm wasting resources of the browser keeping that working when it has finished. Is it just paranoia coming from my C++ past?

@pitbuller: I believe that flag is for the AppletLoader, which I'm not using.@Scarzzurs: I don't run the applet in a browser, but in the Eclipse IDE.

I'll try to give more information.

I run the applet using the Eclipse IDE. As the applet starts, I see in the debug view the main threads running. When I close the applet window I see that the game thread stops running because 1) I stop watching the FPS debug information I throw to the console, 2) going step by step I see the game loop ends, finishing the run() function of the thread, and 3) after that it passes a gameThread.join() statement. I believe that will assure that the game thread is over. However I still some threads running that belong to the CustomApplet (derivated from Applet class) I made.

I'm pretty sure it's not something I did wrong in CustomApplet because I see the same behavior when running in Eclipse the Gears applet that LWJGL provides (not the web applet that actually displays the gears).

The link runs and closes down just fine, for me, when viewed via my browser. (Takes maybe about a second for the Java Console to also disappear.) Eclipse may be a bit sluggish in comparison, since it is an emulation.

In general, you write "stop()" and "destroy()" methods if you want to take explicit control of how your Applet closes itself down.

I agree with ra4king. As long as it IS shutting down, why worry about the few seconds it takes to do so. Don't worry about optimizing everything until the game is playable start to finish. Then make it better... or release it and carry on to the next game, knowing what to do and what not to do... Otherwise you'll end up like me - It'll probably be a year before my game is done, I can only hope I still feel like writing this game in 6 months from now.

I think I got through the denial phase of my paranoia already. Thanks folks!

I was worried about being rude by uploading a inefficient applet. I didn't want to give a wrong impression in my #LD48 game, though I think there are more pressing problems in my games (for instance, I have never made a game, which I think it's a great problem D:).

I'll focus on making games now on, I won't let my paranoia prevent me from success. Thanks!

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org