At work I'm part of a reading group that's going through Java Concurrency in Practice. This week we're reading chapter 7 on Task Cancellation and the authors discuss the difference between how a task and a thread deal with the interruption status bit. The idea is that a task is just borrowing the thread, it doesn't own it, and thus it has a responsibility to be a good steward of thread properties - the interrupted flag in this case. Their point is helpfully illustrated with this real life example:

If you are house-sitting for someone, you don't throw out the mail that comes while they're away - you save it and let them deal with it when they get back, even if you do read their magazines.
Goetz, Brian. Java Concurrency in Practice. New Jersey: Addison-Wesley, 2006

I found the illustration humorous and also appreciated the authors ability to reduce the idea to something any layman could understand. I highly recommend the book to anyone who is doing multi-threaded programming in Java (and probably C# as well). It's given me a much better understanding of the concepts and made me more aware of the complexities of multi-threaded software.

Sorry, comments are closed for this article.