title: Concurrency Primitives in Scala
body: <p>What would be a good concurrency primitives for accessing of an object that is CPU bound(without IO and Networking)? </p>
  
  <p>For example, there's a FooCounter, which has a methods get(), set() and inc() for var counter: Int, that being shared among thousands and millions of threads.</p>
  
  <pre><code>object FooCounter{
    var counter: Int = 0;
    def get() = counter
    def set(value: Int) = {counter = counter + value} 
    def inc() = counter + 1
  }
  </code></pre>
  
  <p>I found that most literature on Scala is oriented about Akka. For me it seems that Actor model is not really suitable for this task. </p>
  
  <p>There's also Futures/Promises but they are good for blocking tasks.</p>
  
  <p>In Java there's a good primitive Atomics that uses latches, which is pretty robust and descent for this task. </p>
  
  <p><strong>Update:</strong>
  I can use Java primitives for this simple task. However, my objective to use and learn Scala Concurrency model on this simple example.</p>