R
Robert Mark Bram
Hi Vévé,
You can interrupt the thread - by calling interrupt() on it. This has some
consequences:
- your thread's blocking operation should be surrounded by a try-catch that
will deal with InterruptedException.
- the code that is responsible for interrpting the thread needs to have
reference to the thread itself in order to call interrupt on it.
- before interrupting the thread, you should set some sort of flag on your
thread to indicate it should be 'stopped' so that your io thread doesn't go
back to blocking..
Good luck!
Rob
I have a poblem with threads : I program multi-threaded applications for a
short time.
I would know how it would be possible to stop a thread which is running a
bloking operation (such i/o functions, server accept(), ...). My app is
waiting indefinitely for the thread to die and that's normal. so how to
stop this thread ?
You can interrupt the thread - by calling interrupt() on it. This has some
consequences:
- your thread's blocking operation should be surrounded by a try-catch that
will deal with InterruptedException.
- the code that is responsible for interrpting the thread needs to have
reference to the thread itself in order to call interrupt on it.
- before interrupting the thread, you should set some sort of flag on your
thread to indicate it should be 'stopped' so that your io thread doesn't go
back to blocking..
Good luck!
Rob