This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A backend thread, need advice

 
J You
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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
message.
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
working.
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
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From MS site:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q227210
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
Hi,
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.
Thanks,
Manfred.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic