Jump to content

  • Log In with Google      Sign In   
  • Create Account


[java] Simple Applet Question.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Wrathnut   Members   -  Reputation: 345

Like
Likes
Like

Posted 25 May 2000 - 10:16 AM

HI, I have a simple applet question I was hoping someone could help me with. I just installed communicator 4.72 on my development machine and I noticed that all of my applets, previous ones that worked fine and the current ones were getting an error in the console window.. sometimes they wouldn''t even load up. Apparently it''s running the symantec JIT which supports java 1.1.5, Now I know why my applets are getting messed up. If you are compiling with java 1.1.3 or prior releases you are supposed to add this line at the end of you main() System.exit(0); This is all well and good, it''s an easy fix.. But all of my applets implement runnable interface so I can thread the animations. Anyway I added that line at the end of the stop() function. That fixxed it so my applets would load, but if I try to goto a different page with a different applet or reload that page I get an error in the console that sometimes makes the applet not run. I believe the error is basically "java.lang.illegalMonitorStateException: current thread not owner" Which I''m not sure if I understand... I guess I don''t know enough about threads to fix it. Any input would help. And if anyone would like to see some code I can post that too. War doesn't determine who is right, war determines who is left.

Sponsor:

#2 Jim_Ross   Members   -  Reputation: 122

Like
Likes
Like

Posted 26 May 2000 - 06:39 AM

Using java.lang.System.exit(int) in an applet is bad. Don''t do it. Generally what the specs tell you to do to handle Threads is to enclose the body of the thread''s run() method with a while(boolean) {...} statement. like:

public void run() {
while(is_running) {
...
}
}
And so, when you want to stop that thread, set is_running to false. It is like this because the thread''s start() & stop() methods are buggy. So at the end of your applet''s stop() set all the thread control booleans to false, and in the applet''s start() set them to true (you may have to call thread.run() again} and in the destroy() set them all to null, including the current thread, which you can get by doing
Thread t = Thread.currentThread();
t = null;




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS