Programming with Concurrency: Threads, Actors, and Coroutines

Zhen Li, Eileen Kraemer
2013 2013 IEEE International Symposium on Parallel & Distributed Processing, Workshops and Phd Forum  
We describe an elective upper-division undergraduate / graduate course that focuses on programming with concurrency and puts into practice topics from the PDC curriculum. We introduce three approaches to concurrent programming: threads (using Java), Actors (using Scala) and Coroutines (using Python) for both shared memory and message passing applications. We also address synchronization issues such as race conditions, conditional synchronization, deadlock and fairness. We use a pseudocode
more » ... on to support language-independent evaluation of students' comprehension of concurrency concepts. Students engage in intensive lab sessions to implement solutions to classical problems in concurrency. We present data analyses that we hope will provide insight and inform the pedagogy associated with concurrent programming. Concurrency; programming; undergraduate curriculum I. B. Scala and the Actors Model Scala is a recently popularized general purpose programming language that integrates features of objectoriented and functional languages. Scala programs also run on Java virtual machines and the program byte code is compatible with Java. Therefore, Scala allows usage of existing Java libraries and application packages. Scala programs may be called from Java and vice versa, with seamless integration. Accordingly, it is possible to implement concurrency and synchronization in Scala by using Java threads artifacts with the java.lang.Thread and java.util.concurrent libraries, which provide several thread definition mechanisms, inter-thread communication mechanisms and some high-level synchronized object classes. The thread synchronization and monitor models available in Java are also fully accessible in Scala. However, Scala differs from the Java programming language in that it provides another means to implement concurrencythe Actor model. An Actor model is a mathematical theory of computation that treats "Actors" as the universal primitives of concurrent digital computation [2] . An Actor is a computational entity that, in response to a message it receives, can concurrently:
doi:10.1109/ipdpsw.2013.193 dblp:conf/ipps/LiK13 fatcat:2zqabjg57vcjxm474vfwzraleu