simple java IPC

Beattie

Golden Member
Sep 6, 2001
1,774
0
0
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.
 

Koing

Elite Member <br> Super Moderator<br> Health and F
Oct 11, 2000
16,843
2
0
^ as I do Java also.

You need to share a few strings between the children of a common parent.
 

FeathersMcGraw

Diamond Member
Oct 17, 2001
4,041
1
0
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.