No announcement yet.

java volatile

  • Filter
  • Time
  • Show
Clear All
new posts

  • java volatile

    Now that we are using channel mult-threading I was wondering how the java code works with the GlobalMap. Is it a variable that is set to volatile?

    After reading this link below on the keyword, I was wondering if mirth threads are always going to be accessing the global map from main memory and not a CPU cache.

    (In the past I had the mirth connect source code building on my machine, but since then I have not updated it for a couple years.)

    Hopefully the coders at Mirth can answer and look into this...

    I think the HashMap object is of the java.util.concurrent package, so that is making it work safely...
    Last edited by StickyBandit; 11-21-2019, 10:02 AM.

  • #2
    There is only one instance of globalMap that never changes, so it doesn't need to be volatile. The object itself is a custom mirth class, but it is backed by java.util.concurrent.ConcurrentHashMaps, so it should be thread-safe.


    • #3
      That isn't to say that you can't run into race conditions if you aren't using it properly. Use of the globalMap should be very rare for supporting regular message processing. You may need to create locks to ensure that certain actions don't run simultaneously.