src/Pure/Concurrent/counter.scala
changeset 78243 0e221a8128e4
parent 75393 87ebf5a50283
equal deleted inserted replaced
78242:633ae08625d1 78243:0e221a8128e4
    16 
    16 
    17 final class Counter private {
    17 final class Counter private {
    18   private var count: Counter.ID = 0
    18   private var count: Counter.ID = 0
    19 
    19 
    20   def apply(): Counter.ID = synchronized {
    20   def apply(): Counter.ID = synchronized {
    21     require(count > java.lang.Long.MIN_VALUE, "counter overflow")
    21     require(count > Long.MinValue, "counter overflow")
    22     count -= 1
    22     count -= 1
    23     count
    23     count
    24   }
    24   }
    25 
    25 
    26   override def toString: String = count.toString
    26   override def toString: String = count.toString