Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (293)
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 and Browser Refresh Hangs  (Read 1056 times)
0 Members and 1 Guest are viewing this topic.
Offline elias4444

Junior Member





« Posted 2004-03-11 02:06:17 »

Well, I once again call upon the great goodness of this forum...maybe I've just been doing too much Java programming lately?

Anyway...I'm stuck: I've created a fun little Java applet to run in a browser. It actually loads on multiple pages of a website. Only problem is, often when someone refreshes a page, the browser hangs. It happens in both IE and Mozilla.

So what else could I do? I open the Java Console to see what's going one while the browser is hung...the page instantly loads up and I never see an error. So, I then open the console before ever loading the pages...and then it never hangs.

I'd love to just tell everyone to leave their Java console open, but I don't think that's going to be very realistic. Has anyone seen this before? And more importantly, has anyone found a fix for it?

Offline Abuse

JGO Coder


Medals: 2


falling into the abyss of reality


« Reply #1 - Posted 2004-03-11 16:13:15 »

Well, assuming users can refresh other pages containing Applets without causing a lockup, it is undoubtably your Applet that is the cause...
Without seeing any code its gonna be abit tough giving any further help.
Perhaps thread related - are you terminating your rendering Thread correctly (renderThread.join() in applet.stop())

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here!
Offline elias4444

Junior Member





« Reply #2 - Posted 2004-03-11 16:55:12 »

Nope. I actually haven't written a stop() method into it. I thought the superclass of JApplet would take care of it. For an emergency solution I did the only thing I know how: In the run loop for the thread, I tell it to do manual garbage collection (gc()). That's really only a workaround, but it's kept things stable for now.

I've been learning a lot of this on my own, and I'm completely new to applets, so I apologize for my lack of intelligence here. I'm worried about overriding the stop() or destroy() methods since I figured I would probably make them worse. Is this a wrong assumption? If it is, does anyone have a good example of what they should look like?

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Abuse

JGO Coder


Medals: 2


falling into the abyss of reality


« Reply #3 - Posted 2004-03-11 21:54:33 »

Something along the lines of this :-

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
Thread me; //the render Thread
boolean running = false;
//called by the browser, to indicate it wants the Applet to start.
public void start()
{
   running = true;
   me = new Thread(this); //'this' class implements the Runnable interface
  me.start(); //start the render Thread
}


public void run()
{
   //your render loop
  while(running)
   {


   }
}

//called by the browser when it wants the Applet to terminate
public void stop()
{
   running = false;
   me.join(); //wait for the render Thread to complete cleanly
}

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here!
Offline elias4444

Junior Member





« Reply #4 - Posted 2004-03-12 01:45:10 »

Thank you! Do I need to call super.stop() after that? And do I have to just copy the same code block for destroy()?

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

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (84 views)
2013-05-17 21:29:12

alaslipknot (92 views)
2013-05-16 21:24:48

gouessej (123 views)
2013-05-16 00:53:38

gouessej (117 views)
2013-05-16 00:17:58

theagentd (127 views)
2013-05-15 15:01:13

theagentd (114 views)
2013-05-15 15:00:54

StreetDoggy (158 views)
2013-05-14 15:56:26

kutucuk (180 views)
2013-05-12 17:10:36

kutucuk (180 views)
2013-05-12 15:36:09

UnluckyDevil (187 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.117 seconds with 21 queries.