Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (601)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (649)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Applet takes long to exit  (Read 1165 times)
0 Members and 1 Guest are viewing this topic.
Offline yuma

Junior Devvie

Medals: 2
Projects: 1

Monkeys are listening

« Posted 2011-12-15 10:49:17 »

Hi there! First post (of many to come, I hope).

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?

Thanks in advance!

Offline pitbuller
« Reply #1 - Posted 2011-12-15 12:19:56 »

 if <code>al_debug</code> is true the applet will load and extract resources with a delay, to be able to see the loader process.

Check this.
Offline Scarzzurs
« Reply #2 - Posted 2011-12-15 12:26:12 »

This is probably not the problem, but it's also worth noting that the Applet JVM usually doesn't shut down right after you close the browser tab (if run in a browser)...

- Scarzzurs

My games and Projects:,
Old website
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline yuma

Junior Devvie

Medals: 2
Projects: 1

Monkeys are listening

« Reply #3 - Posted 2011-12-15 12:37:33 »

Thanks for your answers.

@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).

Thanks again and I hope now it's clearer!

Offline ra4king

JGO Kernel

Medals: 389
Projects: 3
Exp: 5 years

I'm the King!

« Reply #4 - Posted 2011-12-15 23:58:25 »

If your game loop ends, then all is fine. It's just your paranoia Grin

Offline philfrei
« Reply #5 - Posted 2011-12-16 01:27:23 »

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.

"We all secretly believe we are right about everything and, by extension, we are all wrong." W. Storr, The Unpersuadables
Offline ra4king

JGO Kernel

Medals: 389
Projects: 3
Exp: 5 years

I'm the King!

« Reply #6 - Posted 2011-12-16 02:40:09 »

There's nothing really he can do in stop/destroy that can cause a "faster" shutdown. I still say it's paranoia. Write a freaking game already!! Grin

Offline gbeebe

Senior Devvie

Medals: 5
Projects: 1

« Reply #7 - Posted 2011-12-16 04:20:08 »

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.
Offline yuma

Junior Devvie

Medals: 2
Projects: 1

Monkeys are listening

« Reply #8 - Posted 2011-12-16 09:38:07 »

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

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!

Kitties FTW!

Offline ra4king

JGO Kernel

Medals: 389
Projects: 3
Exp: 5 years

I'm the King!

« Reply #9 - Posted 2011-12-16 21:48:29 »

Kittens for #LD48!!!! Cheesy

Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Jesse (11 views)
2015-07-29 04:35:27

Riven (33 views)
2015-07-27 16:38:00

Riven (16 views)
2015-07-27 15:35:20

Riven (20 views)
2015-07-27 12:26:13

Riven (10 views)
2015-07-27 12:23:39

BurntPizza (28 views)
2015-07-25 00:14:37

BurntPizza (39 views)
2015-07-24 22:06:39

BurntPizza (22 views)
2015-07-24 06:06:53

NoxInc (25 views)
2015-07-22 22:16:53

NoxInc (17 views)
2015-07-22 22:13:39
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 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‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!