Is it possible to shut down the session notifier?
If all else fails, call Runtime.getRuntime().addShutdownHook(...) to
set up what should happen when you shut down. Then call System.exit(0).
Kind regards
Heinz
--
Dr Heinz M. Kabutz (PhD CompSci - University of Cape Town)
Sun Java Champion
Author of "The Java(tm) Specialists' Newsletter"
http://www.javaspecialists.co.za
Tel: +27 (83) 340-5633
Skype: kabutz
Fritz Meissner wrote:
Unfortunately, I don't create the listener thread. I just
say,
sessionnotifier.acceptAndOpen(ListenerObj)
And all the threading is done for me. From what I can see I need to
call that setDaemon method before starting the thread.
Fritz
On 10/6/06, Chris Hughes <[EMAIL PROTECTED]>
wrote:
A quick and nasty fix for this problem would be
"listener_thread.setDaemon(true)". This will cause the listener thread
to terminate once the main thread is finished.
This won't fix the underlying problem, but it should help in
the mean time.
Regards,
Chris
On 10/6/06, Fritz Meissner <[EMAIL PROTECTED]
> wrote:
Hi,
Can anyone tell me, what are common reasons why threads hang around and
stop a program from exiting once all its work is done? I have the
following situation:
1. Main thread calls a method, which starts up a thread to do stuff,
and sets up a listener for certain events
2. The listener informs the main thread once its work is complete
3. Main thread sleeps until it hears from the listener that the new
thread's work is finished
4. Main thread does some more work and then exits
At this point I would expect the program to exit, but it doesn't.
I should point out that I don't know the internals of what the new
thread is doing, that code is hidden from me. This is all in the
context of communicating using JSR-82 for Bluetooth; I am using the
Avetana implementation. Their technical support guy to whom I've been
talking says he is unable to duplicate the problem. I find this
disturbing, because the starting point for my code was the sample code
he's testing.
And then another question: where do most people learn how to use
threads properly? I've been "taught" threading - but all that involved
was learning how to create threads; there was nothing about where to
use what, how to avoid deadlock etc. Also nothing specific to Java -
only C/C++ for an operating systems course.
Fritz
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CTJUG Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/CTJUG-Forum
For the ctjug home page see http://www.ctjug.org.za -~----------~----~----~----~------~----~------~--~---
|