Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2007

Tip: Looking for answers? Try searching our database.

<applet><realease resources>

Thread view: 
tony - 17 Jun 2007 04:48 GMT
Hi,
 I have an applet embedded in html and a while-true-loop is running
in the applet. When the applet is running, I type another URL
(e.g. http://www.google.com), then what event will be triggered or how
can I stop the while-true-loop on this event?

Thank you!
Andrew Thompson - 17 Jun 2007 08:12 GMT
...
>  I have an applet embedded in html and a while-true-loop is running
>in the applet. When the applet is running, I type another URL
>(e.g. http://www.google.com), then what event will be triggered or

Applet stop or destroy might be called on
minimise and page unload.

Applet.destroy() // though some browsers do not call it
A (for example) rendering applet might also call a stop
in Applet.stop().

> ..how can I stop the while-true-loop on this event?

Make it a while-classAttribute-true boolean.  Set
the attribute from stop and destroy (as well as
init()/start()).

Signature

Andrew Thompson
http://www.athompson.info/andrew/

tony - 17 Jun 2007 09:34 GMT
> ..
>>  I have an applet embedded in html and a while-true-loop is running
[quoted text clipped - 13 lines]
> the attribute from stop and destroy (as well as
> init()/start()).

Actually, I wrote:
System.out.println("** destroying...");
in destroy() and
System.out.println("** stopping...");
in stop(), but nothing happened!
Neither of them was printed when I switch
to another page.
Andrew Thompson - 17 Jun 2007 10:50 GMT
>> ..
>>>  I have an applet embedded in html and a while-true-loop is running
...
>> the attribute from stop and destroy (as well as
>> init()/start()).
>
>Actually, I wrote:
>System.out.println("** destroying...");
...
>Neither of them was printed when I switch
>to another page.

Web start* seems to call stop() and destroy()
reliably at applet close.  * That results in a free
floating applet on launch.  e.g.
<http://www.physci.org/jws/#jtest>

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Roedy Green - 17 Jun 2007 08:23 GMT
>  I have an applet embedded in html and a while-true-loop is running
>in the applet. When the applet is running, I type another URL
>(e.g. http://www.google.com), then what event will be triggered or how
>can I stop the while-true-loop on this event?

You should not do that in an Applet since all Applets on a page share
the same thread.  You should spawn a separate thread or arrange to get
an event periodically to do a little work. See
http://mindprod.com/jgloss/thread.html
http://mindprod.com/jgloss/timer.html

If you tie up the main thread no Swing painting can happen either.
.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
tony - 17 Jun 2007 09:39 GMT
>>  I have an applet embedded in html and a while-true-loop is running
>> in the applet. When the applet is running, I type another URL
[quoted text clipped - 13 lines]
> The Java Glossary
> http://mindprod.com
If I use threads to do it, how can I interrupt it or destroy it
when I switch to another page?
The key problem is that either destroy() or stop() is not called
and I don't know if there is any other event will be triggered?
Roedy Green - 22 Jun 2007 12:08 GMT
>If I use threads to do it, how can I interrupt it or destroy it
>when I switch to another page?
>The key problem is that either destroy() or stop() is not called
>and I don't know if there is any other event will be triggered?

Threads share variables.  There are all kinds of ways for threads to
communicate.  See http://mindprod.com/jgloss/thread.html

This is pretty complicated. You might want to get a textbook to
explain it or poke around in the new java.util.concurrent package
which has canned solutions to common problems.

see http://mindprod.com/jgloss/queue.html
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.