Teaching students to develop thread-safe java classes

Concurrent programming was once the preserve of experts writing systems internals; but recently the growing importance of application servers, and the excellent support in Java and C# for thread handling, has brought threads and locking as topics that every software developer might experience, and therefore every computer science graduate ought to know. In this paper we report on several years of experience teaching this material in the early years of the curriculum. We focus on one aspect of multi-threaded code, namely how to write sensible thread-safe classes. We identify the learning outcomes we aim to deliver, and we discuss the main pedagogic difficulties students find. We present some examples that can help students avoid common erroneous views.