RE: [Simpleweb-Support] Shutdown
Brought to you by:
niallg
|
From: Lars A. <la...@un...> - 2004-05-06 17:06:52
|
Hi,
There is a lot of threads created (not only PipelineProcessor and =
connection threads).
Setting them to daemon solves the application termination problem.
If I create a LoaderEngine there is no method to kill the threads it =
spawns. I tried to add a kill() on LoaderEngine that called Kill() on =
the context.Kill() delegate.Kill(). FileContext.Kill() calls =
cache.Kill(). Cache.Kill() calls cleaner.Kill().
CacheCleaner.Kill() and Processor().Kill() sets a alive flag to false. =
Unfortunately this did not work as some threads seam to be stuck in a =
wait(). A Thread.interupt() solved this problem (don't know if =
interrupt() is a good solution...)
I did the same for Connection.
for (int i =3D 0; i < 50; i++) {
LoaderEngine engine =3D new LoaderEngine();
ProtocolHandler handler =3D HandlerFactory.getInstance(engine);
Connection connection =3D ConnectionFactory.getConnection(handler);
socket =3D new ServerSocket(8282);
connection.connect(socket);
Thread.sleep(100);
socket.close();
UnicastRemoteObject.unexportObject(engine, true);
engine.kill();
connection.kill();
}
After the modifications the above code will no longer leave junk =
threads.
Would you consider adding cleanup functions that enable terminating =
threads belonging to unused objects?
/Lars
-----Original Message-----
From: Niall Gallagher [mailto:ni...@em...]=20
Sent: den 5 maj 2004 20:25
To: sim...@li...
Subject: Re: [Simpleweb-Support] Shutdown
Hi,
Closing the socket with ServerSocket.close() will terminate all =
connection threads for that socket, however this will still leave active =
poller threads within the PipelineProcessor active. I have to admit that =
this has been overlooked, however you can extend the PipelineProcessor =
and terminate all threads within the Vector named active which contains =
all active Poller threads. Really the PiplineProcessor threads should be =
daemon threads as of Thread.setDaemon(true), ill make sure to include =
this fix in the next release.
Regards
Niall
----- Original Message -----
From: "Lars Arvidson"=20
Date: Wed, 5 May 2004 19:21:48 +0200
To:=20
Subject: [Simpleweb-Support] Shutdown
Hi!
I tried the code in the getting started tutorial and added a .close() on =
the socket hoping it would terminate all threads and make the test =
application exit.
=A0=A0=A0=A0=A0 public static void main(String[] args) throws Exception =
{
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 LoaderEngine engine =3D new =
LoaderEngine();
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 engine.load("default", =
"test.MainService");
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 engine.link("*", "default");
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ProtocolHandler handler =3D =
HandlerFactory.getInstance(engine);
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Connection connection =3D =
ConnectionFactory.getConnection(handler);
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ServerSocket socket =3D new =
ServerSocket(8282);
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 connection.connect(socket);
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Thread.sleep(1000);
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 socket.close();
=A0=A0=A0=A0=A0 }
This did not terminate the application.
I also tied with ProcessQueue.getInstance().stop().
The only way I found to terminate the application was System.exit().
Is there another way to terminate the worker threads?
What is the recommended approach to terminate the application?
/Lars=20
--=20
___________________________________________________________
Sign-up for Ads Free at Mail.com
http://promo.mail.com/adsfreejump.htm
-------------------------------------------------------
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to=20
deliver higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=3Dosdnemail3
_______________________________________________
Simpleweb-Support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simpleweb-support
|