• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

simple java IPC

Beattie

Golden Member
Is there a simple method for communication between threads in Java? I just need to share a few strings between the children of a common parent.
 
^ as I do Java also.

You need to share a few strings between the children of a common parent.
 
Not as part of the standard library, although you could probably cook your own using the java.io package.

You should probably think about why you want IPC in the first place, though, if your ultimate goal is to pass values between threads. If you want globally accessible state, consider making the shared members static (assuming that your threads all inherit from a common class) -- of course, making sure that access to those fields is synchronized to avoid race conditions. An alternative might be to wrap the shared state in an object (again making sure that read/write access is properly synchronized) and making sure that all of the interested threads have a reference to the shared state object when they are constructed.
 
Back
Top