views:

3605

answers:

4

Dear all,

what is the best method for inter process communication in a multithreaded java app.

It should be performant (so no JMS please) easy to implement and reliable,so that objects & data can be bound to one thread only?

Any ideas welcome!

Thanks Okami

+7  A: 

Could you clarify a bit? Do you mean IPC in a single JVM? (Multiple threads, yes, but at an OS-level only one process.) Or do you mean multiple JVMs? (And truly OS-level inter process communications.)

If it is the first, then maybe something out of java.util.concurrent, like ConcurrentLinkedQueue would do the trick. (I pass message around inbetween my threads with classes from java.util.concurrent with success.)

If the later, then I'm going to just guess and suggest taking a look at RMI, although I don' think it qualifies as fully reliable--you'd have to manage that a bit more 'hands on' like.

Stu Thompson
RMI is by far the best way for IPC between different JVMs.
trshiv
+2  A: 

I recommend looking into the entire java.util.concurrent package, which have multiple classes for dealing with concurrency and different communication means between threads. All depends on what you want to achieve, as your question is pretty general.

Staale
+4  A: 

Assuming the scenario 1 JVM, multiple threads then indeed java.util.concurrent is the place to look, specifically the various Queue implementations. However an abstraction on top of that may be nice and there Jetlang looks very interesting, lightweight Java message passing.

Boris Terzic
+1  A: 

Thanks for the answers. Of course I thought about the java.util.concurrent package but now I will evaluate Jetlang 'cause it seems to be what I searched for.

Okami