web stats
java volatile - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 11-21-2019, 09:57 AM
StickyBandit's Avatar
StickyBandit StickyBandit is offline
Mirth Guru
 
Join Date: Aug 2013
Location: Home Alone
Posts: 955
StickyBandit is on a distinguished road
Arrow 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.


http://tutorials.jenkov.com/java-con.../volatile.html



(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 at 10:02 AM.
Reply With Quote
  #2  
Old 11-22-2019, 04:40 AM
agermano agermano is online now
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,164
agermano is on a distinguished road
Default

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.
Reply With Quote
  #3  
Old 11-22-2019, 04:43 AM
agermano agermano is online now
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,164
agermano is on a distinguished road
Default

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.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 01:53 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Mirth Corporation