Stopping a thread always gives me some headache. This time i have a class written which usesa Thread to indefinitly reads data from a stream. Now it shall be possible for the environment, which instantiated this communication class to stop the work.
The big problem is that the stream which is read isnt a fluent one, moreover a slow consumer/producer thing over com-port. So if i try somethign like this:
exec = false;
it can take quite a time that the flag is noticed to be negative so that the loop exists. how can i elegantly stop and dispatch the Thread?