Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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 887 times)
0 Members and 1 Guest are viewing this topic.
Offline yuma

Junior Member


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 »

 
1  
 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:
BlastingPixels.com,
Old website
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline yuma

Junior Member


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: 345
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.

http://docs.oracle.com/javase/tutorial/deployment/applet/lifeCycle.html

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline ra4king

JGO Kernel


Medals: 345
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 Member


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 Member


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: 345
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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (25 views)
2014-09-19 03:14:18

Dwinin (39 views)
2014-09-12 09:08:26

Norakomi (68 views)
2014-09-10 13:57:51

TehJavaDev (93 views)
2014-09-10 06:39:09

Tekkerue (47 views)
2014-09-09 02:24:56

mitcheeb (68 views)
2014-09-08 06:06:29

BurntPizza (51 views)
2014-09-07 01:13:42

Longarmx (38 views)
2014-09-07 01:12:14

Longarmx (44 views)
2014-09-07 01:11:22

Longarmx (40 views)
2014-09-07 01:10:19
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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
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!