Understanding Synchronization and Data Access with system.util.getGlobals

  1. No. Jython collections, sets, and dictionaries are all based on java "Concurrent" underlying classes, so they are thread-safe, but algorithms built with them are not.

  2. Yes. Java is highly multithreaded, so any thread waiting on a mutex could block actions that do not expect to wait (like the tag event thread pool).

  3. Not in and of itself, no.

  4. (Yeah, you didn't have "4".) The object returned from system.util.getGlobals() also holds top-level variables in gateway events. Yes, shared across the entire gateway. Access to those was/is part of its design. I created alternatives (now system.util.globalVarMap() in my Integration Toolkit) to avoid this particular complication. (There used to be more problems.)

Careful use of .setdefault on Jython dictionaries, and .putIfAbsent() on ConcurrentHashMaps can reduce the need for mutexes or other locks. Consider this topic:

Related: If you always use one-liners in your gateway events that delegate to project library scripts, then you aren't creating any top-level variables that could clash with other residents of system.util.getGlobals().

1 Like