• Post Reply Bookmark Topic Watch Topic
  • New Topic

A backend thread, need advice

J You
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am given an assignment to solve following problem:
We have a website and our clients can login
in and do there works.Sometimes we have to
shutdown the server and we need let the clients
who are still using the site get the warning
My solution is to write an applet and embed it
in the first login page. This applet will create
a new thread which can send request to the server
in a no-end-loop(every 10 minutes sleep),and if it
got the warning response, then it will show a
popup window with message like "The server will
shutdown at 3PM,please save your work before 3PM".
I start the thread in Applet.start() method,
and clear it to NULL in Applet.destroy() method,
do thing in the stop() method so that even the
user goes to the other pages,the thread is still
But when I test the applet with different browsers,it behave differently:
With Sun Hotjava, this approach works.The only
problem is that the thread can only be stopped
when the browser is closed. That is,the Applet.destroy() method is not called until the
user close the browser(this is not perfect,but
we can accept since it works).
So,the cycle is like following:
enter into the login page -- call init(),start().
Leave the login page and go to other pages in the
same site --- call Applet.stop() method.
Leave the site --- call Applet.stop() method.
Close browser --- call Applet.destroy() method.
With IE5,in some computer, it works in the same
way as the Hotjava.But,in some other computer,
once the user leaves the Login page, the Applet's
destroy() method is called.
So the problem is that we are not sure when the
Applet's destroy() method is called.If it is
called too early,then the approach fails.
The browser at client side is uncertain,we only
know it is IE4.0 or above.
Any advice is apperiated!
J You
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From MS site:
It seems in IE3.0, destroy() method is called
until the browser is closed; from IE4.0, the
stop() and destroy() methods are called when
user leaves the page.
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read the JavaRanch naming policy here and re-register with a valid professional login name. We like to keep this site professional with login names of firstName + space + lastName.
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!