Skip to main content
The 2024 Developer Survey results are live! See the results
the alleged duplicate asks specifically about preserving order, also response ina not a place for comments like that IMHO
Source Link
Paweł Prażak
  • 3.2k
  • 1
  • 29
  • 42
  1. You're duplicating topics....

  2. As was mentioned by AlexIv in his answer, there's a trait you can mix in if you want thread safety. There's another way though:

     val synchronizedMap = new scala.collection.mutable.LinkedHashMap[String, Any]() with scala.collection.mutable.SynchronizedMap[String, Any]
    

As was mentioned by AlexIv in his answer, there's a trait you can mix in if you want thread safety. There's another way though:

    val synchronizedMap = new scala.collection.mutable.LinkedHashMap[String, Any]() with scala.collection.mutable.SynchronizedMap[String, Any]

That should give you the map with synchronization on each accessmap with synchronization on each access. Easy, but might not meet the performance requirements. If so, it would be probably easier to create a custom class extending the LinkedHashMap, mixing in the concurrent.Map trait (as was suggested) and provide the implementation of relevant methods, i.e: putIfAbsent, remove replace (2 overloads).

  1. You're duplicating topics....

  2. As was mentioned by AlexIv in his answer, there's a trait you can mix in if you want thread safety. There's another way though:

     val synchronizedMap = new scala.collection.mutable.LinkedHashMap[String, Any]() with scala.collection.mutable.SynchronizedMap[String, Any]
    

That should give you the map with synchronization on each access. Easy, but might not meet the performance requirements. If so, it would be probably easier to create a custom class extending the LinkedHashMap, mixing in the concurrent.Map trait (as was suggested) and provide the implementation of relevant methods, i.e: putIfAbsent, remove replace (2 overloads).

As was mentioned by AlexIv in his answer, there's a trait you can mix in if you want thread safety. There's another way though:

    val synchronizedMap = new scala.collection.mutable.LinkedHashMap[String, Any]() with scala.collection.mutable.SynchronizedMap[String, Any]

That should give you the map with synchronization on each access. Easy, but might not meet the performance requirements. If so, it would be probably easier to create a custom class extending the LinkedHashMap, mixing in the concurrent.Map trait (as was suggested) and provide the implementation of relevant methods, i.e: putIfAbsent, remove replace (2 overloads).

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot
  1. You're duplicating topics....You're duplicating topics....

  2. As was mentioned by AlexIv in his answerAlexIv in his answer, there's a trait you can mix in if you want thread safety. There's another way though:

     val synchronizedMap = new scala.collection.mutable.LinkedHashMap[String, Any]() with scala.collection.mutable.SynchronizedMap[String, Any]
    

That should give you the map with synchronization on each access. Easy, but might not meet the performance requirements. If so, it would be probably easier to create a custom class extending the LinkedHashMap, mixing in the concurrent.Map trait (as was suggested) and provide the implementation of relevant methods, i.e: putIfAbsent, remove replace (2 overloads).

  1. You're duplicating topics....

  2. As was mentioned by AlexIv in his answer, there's a trait you can mix in if you want thread safety. There's another way though:

     val synchronizedMap = new scala.collection.mutable.LinkedHashMap[String, Any]() with scala.collection.mutable.SynchronizedMap[String, Any]
    

That should give you the map with synchronization on each access. Easy, but might not meet the performance requirements. If so, it would be probably easier to create a custom class extending the LinkedHashMap, mixing in the concurrent.Map trait (as was suggested) and provide the implementation of relevant methods, i.e: putIfAbsent, remove replace (2 overloads).

  1. You're duplicating topics....

  2. As was mentioned by AlexIv in his answer, there's a trait you can mix in if you want thread safety. There's another way though:

     val synchronizedMap = new scala.collection.mutable.LinkedHashMap[String, Any]() with scala.collection.mutable.SynchronizedMap[String, Any]
    

That should give you the map with synchronization on each access. Easy, but might not meet the performance requirements. If so, it would be probably easier to create a custom class extending the LinkedHashMap, mixing in the concurrent.Map trait (as was suggested) and provide the implementation of relevant methods, i.e: putIfAbsent, remove replace (2 overloads).

typo & grammar fixes
Source Link
Patryk Ćwiek
  • 14.3k
  • 3
  • 57
  • 76
  1. You're duplicating topics....

  2. As was mentioned by AlexIv in his answer, there's a trait you can mix in if you want thread safety. There's another way though:

     val synchronizedMap = new scala.collection.mutable.LinkedHashMap[String, Any]() with scala.collection.mutable.SynchronizedMap[String, Any]
    

That should give you the map with synchronization on each access. Easy, but might not meet the performance requirements. If so, it woulwould be probably the easiesteasier to create a custom class extending the LinkedHashMap, mixing in the concurrent.Map trait (as was suggested) and provide the implementation of relevant methods, i.e: putIfAbsent, remove replace (2 overloads).

  1. You're duplicating topics....

  2. As was mentioned by AlexIv in his answer, there's a trait you can mix in if you want thread safety. There's another way though:

     val synchronizedMap = new scala.collection.mutable.LinkedHashMap[String, Any]() with scala.collection.mutable.SynchronizedMap[String, Any]
    

That should give you the map with synchronization on each access. Easy, but might not meet the performance requirements. If so, it woul be probably the easiest to create a custom class extending the LinkedHashMap, mixing in the concurrent.Map trait (as was suggested) and provide the implementation of relevant methods, i.e: putIfAbsent, remove replace (2 overloads).

  1. You're duplicating topics....

  2. As was mentioned by AlexIv in his answer, there's a trait you can mix in if you want thread safety. There's another way though:

     val synchronizedMap = new scala.collection.mutable.LinkedHashMap[String, Any]() with scala.collection.mutable.SynchronizedMap[String, Any]
    

That should give you the map with synchronization on each access. Easy, but might not meet the performance requirements. If so, it would be probably easier to create a custom class extending the LinkedHashMap, mixing in the concurrent.Map trait (as was suggested) and provide the implementation of relevant methods, i.e: putIfAbsent, remove replace (2 overloads).

Source Link
Patryk Ćwiek
  • 14.3k
  • 3
  • 57
  • 76
Loading