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.
NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
This topic has been locked.
1 reply Latest Post - 2008-02-01T04:51:43Z by SystemAdmin
Pinned topic Passing Config Values to Threads
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2008-02-01T04:51:43Z at 2008-02-01T04:51:43Z by SystemAdmin
SystemAdmin 110000D4XK1240 PostsACCEPTED ANSWER
Re: Passing Config Values to Threads2008-02-01T04:51:43Z in response to SystemAdminIs 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?