• 1 reply
  • Latest Post - ‏2008-02-01T04:51:43Z by SystemAdmin
1240 Posts

Pinned topic Passing Config Values to Threads

‏2008-01-31T16:08:38Z |
I’m working on what should be a simple test program… I have a Driver class that reads in config values then sets up and runs some threads that call Worker and Persistor classes. The config values are stored in/accessed from what is essentially a static SystemConfig class (all methods and fields are static).

The Driver can read properties from the SystemConfig class without a problem, but the Worker and Prersistor classes running in the Threads act like the SystemConfig they are seeing hasn’t been initialized. If I call the Worker directly from the Driver (rather than through the Thread) it sees the initialized values, so it appears to to have something to do with the code running in the context of a Thread.

I’ve played around a bit with the Thread contextClassLoader, but haven’t figured out how it all fits together yet. Any guidance would be appreciated.
Updated on 2008-02-01T04:51:43Z at 2008-02-01T04:51:43Z by SystemAdmin
  • SystemAdmin
    1240 Posts

    Re: Passing Config Values to Threads

    Is SystemConfig fully initialized when it is constructed and immutable? If not, then other threads have no guarantee to see its state, even if everything is static.

    Can not you make SystemConfig an immutable object and pass it to the different threads?