Last active
September 9, 2015 16:49
-
-
Save leifwickland/f1338e50704208d75a26 to your computer and use it in GitHub Desktop.
j.u.c.ConcurrentMap asScala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.ConcurrentHashMap | |
import java.util.concurrent.ConcurrentMap | |
import scala.collection.JavaConverters._ | |
val m: ConcurrentMap[String, String] = new ConcurrentHashMap[String, String] | |
m.put("1", "one") | |
m.put("2", "two") | |
val cm: scala.collection.concurrent.Map[String, String] = m.asScala | |
cm += ("3" -> "three") | |
cm.foreach(println) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~$ scala /tmp/juc.scala | |
(1,one) | |
(2,two) | |
(3,three) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment