• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

A backend thread, need advice

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic