Search code examples
grailsgroovy

do we need to use a mutex lock when accessing Grails global variables?


I'm wondering In grails's global variables - do we need to add mutex lock when access them ? Example

  • Static variable in XXXService Class
  • Grails Application Context

Solution

  • I'm wondering In grails's global variables - do we need to add mutex lock when access them ?

    The JVM doesn't really have global variables. The closest thing to them are public static variables, which isn't really the same thing.

    Whether or not you have to add a mutex depends on what you want to do with the variables. In general, the answer is "no", but that is in part because in general you wouldn't want to have mutable public static variables.