The document discusses concurrency and parallelism in Scala. It notes that manually handling threads and locks is difficult and error-prone. Actors provide a safer model for concurrency by encapsulating state and message-passing. Parallelism can be achieved in Scala through parallel collections that split work over multiple processors. The author advocates building asynchronous systems using actors for concurrency and parallel collections for parallelism to fully utilize hardware resources.
2. About Me
Big Scala Geek
Author of Lift in Action
Coding Scala since 2007
Background in both dynamic
and statically typed languages
Manufacturing and marketing
automation is my day job
h"p://manning.com/perre"/
software. done right.
3. Concurrency
vs
Parallelism
software. done right.
8. Concurrency
Simpler mental model
Much easier to avoid common issues:
Deadlocks
Race Conditions
Starvation
etc
software. done right.
9. Concurrency
case class Increment(amount: Int)
class Counter extends Actor {
private var count = 0
def receive = {
case Increment(by) =>
count += by
println(count)
}
}
software. done right.
24. Summary
Manually handling threads and locks sucks
Actors provide a sane model for concurrency
Build completely asynchronous systems
Get the most out of your hardware investment
software. done right.
25. Further Reading
Scala Language
http://scala-lang.org
Akka Actor Toolkit
http://akka.io/
State: You’re Doing It Wrong
http://www.slideshare.net/jboner/state-youre-doing-it-wrong-javaone-2009
A Generic Parallel Collection Framework
http://infoscience.epfl.ch/record/150220/files/pc.pdf
software. done right.