...
>> My
> >common sense tells me: there is no way to stop thread "in correct
> >manner" if it has no provisions for this. InputStream makes you to poll
> >available() function for non-blocking read. Probably my testing code
> >will give you some assistance in your problem:
> 
> It is hard to have stop() work during blocking I/O on native threaded
> systems since the native threading and I/O blocking may not have a way
> to cleanly "break" out of the blocked I/O state.  The only option may
> be to kill the process (or thread) at a OS level and thus you would
> have a problem of not being able to clean up.

This is what I tried to say. Moreover, with 'green threads' stopped
thread will also have cleanup problem if non-preemptive task manager
calls like Thread.yield() are hidden in the many common API functions.
Again, imho code running in thread must know that it is interruptable
and provide API for well behaving interrupt
(via timeout as DatagramSocket.setSoTimeout() does or directly as
java.sql.Statement.cancel() does).

Pavel

Reply via email to