Book Image

Learning Concurrent Programming in Scala

By : Aleksandar Prokopec
5 (1)
Book Image

Learning Concurrent Programming in Scala

5 (1)
By: Aleksandar Prokopec

Overview of this book

Table of Contents (18 chapters)
Learning Concurrent Programming in Scala
Credits
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Exercises


The following exercises test your understanding of the actor programming model, and distributed programming in general. First few exercises are straightforward, and deal with the basics of the actor API in Akka. Subsequent exercises are more involved, and go deeper into the territory of fault-tolerant distributed programming. Try to solve these exercises by first assuming that no machines fail, and then consider what happens if some of the machines fail during the execution of the program.

  1. Implement the timer actor with the TimerActor class. After receiving a Register message containing the t timeout in milliseconds, the timer actor sends a Timeout message back after t milliseconds. The timer must accept multiple Register messages.

  2. Recall the bank account example from Chapter 2, Concurrency on the JVM and the Java Memory Model. Implement different bank accounts as separate actors, represented with the AccountActor class. When an AccountActor class receives a Send message, it must...