Skip to content
Advertisement

is scala OpenHashMap remove operator threadsafe

Sorry but I cannot find in the network a direct answer to a very simple questions.

is scala OpenHashMap remove operator threadsafe?

Regrds.

Advertisement

Answer

Seems it is not thread safe: Scala OpenHashMap def:

override def remove(key : Key): Option[Value] = {
    val index = findIndex(key)
    if (table(index) != null && table(index).value != None){
      val res = table(index).value
      table(index).value = None
      size -= 1
      deleted += 1
      res
    } else None
  }

Ref link:

https://alvinalexander.com/java/jwarehouse/scala-2.11/library/scala/collection/mutable/OpenHashMap.scala.shtml

Advertisement