Last active
August 29, 2015 14:16
-
-
Save wrobstory/79872b94f0d7bf1720f1 to your computer and use it in GitHub Desktop.
Scala/Java ConcurrentHashMap
This file contains hidden or 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> val mymap = new ConcurrentHashMap[String, Int] | |
mymap: java.util.concurrent.ConcurrentHashMap[String,Int] = {} | |
scala> mymap.put("one", 1) | |
res8: Int = 0 | |
scala> mymap.put("zero", 0) | |
res9: Int = 0 | |
scala> mymap.get("one") | |
res10: Int = 1 | |
scala> mymap.get("zero") | |
res11: Int = 0 | |
scala> mymap.get("two") | |
res12: Int = 0 |
This file contains hidden or 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> val mymap = new ConcurrentHashMap[String, Option[Int]] | |
mymap: java.util.concurrent.ConcurrentHashMap[String,Option[Int]] = {} | |
scala> mymap.put("one", Some(1)) | |
res17: Option[Int] = null | |
scala> mymap.get("two") | |
res18: Option[Int] = null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment