<p>what is the best method for inter process communication in a multithreaded java app.</p>

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

<p>Any ideas welcome!</p>

[{'answer_id': 51479, 'author': 'Stu Thompson', 'author_id': 2961, 'author_profile': 'https://Stackoverflow.com/users/2961', 'pm_score': 4, 'selected': False, 'text': '<p>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.)</p>\n\n<p>If it is the first, then maybe something out of <strong>java.util.concurrent</strong>, like <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ConcurrentLinkedQueue.html" rel="noreferrer">ConcurrentLinkedQueue</a> would do the trick.  (I pass message around inbetween my threads with classes from java.util.concurrent with success.)</p>\n\n<p>If the later, then I\'m going to just guess and suggest taking a look at <strong><a href="http://java.sun.com/javase/technologies/core/basic/rmi/index.jsp" rel="noreferrer">RMI</a></strong>, although I don\' think it qualifies as fully reliable--you\'d have to manage that a bit more \'hands on\' like.</p>\n'}, {'answer_id': 51493, 'author': 'Staale', 'author_id': 3355, 'author_profile': 'https://Stackoverflow.com/users/3355', 'pm_score': 2, 'selected': False, 'text': '<p>I recommend looking into the entire <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/package-summary.html" rel="nofollow noreferrer">java.util.concurrent</a> 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.</p>\n'}, {'answer_id': 51543, 'author': 'Boris Terzic', 'author_id': 1996, 'author_profile': 'https://Stackoverflow.com/users/1996', 'pm_score': 4, 'selected': True, 'text': '<p>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 <a href="http://code.google.com/p/jetlang/" rel="noreferrer">Jetlang</a> looks very interesting, lightweight Java message passing.</p>\n'}, {'answer_id': 13576414, 'author': 'TraderJoeChicago', 'author_id': 124708, 'author_profile': 'https://Stackoverflow.com/users/124708', 'pm_score': 2, 'selected': False, 'text': '<p>You should use a producer/consumer queue. By doing that you avoid the pitfalls of multithreaded programming: race-conditions and deadlocks. Plus it is not just easier and cleaner, but also much faster if you use a lock-free queue like Disruptor or MentaQueue. I wrote a blog article where I talk about this in detail and show how to get &lt; 100 nanoseconds latencies: <a href="http://mentablog.soliveirajr.com/2012/11/inter-thread-communication-with-2-digit-nanosecond-latency/" rel="nofollow">Inter-thread communication with 2-digit nanosecond latency</a>.</p>\n'}, {'answer_id': 30255157, 'author': 'MikaelJ', 'author_id': 4882215, 'author_profile': 'https://Stackoverflow.com/users/4882215', 'pm_score': 2, 'selected': False, 'text': '<p>I\'ve just added MappedBus on github (<a href="http://github.com/caplogic/mappedbus" rel="nofollow">http://github.com/caplogic/mappedbus</a>) which is an efficient IPC library that enable several Java processes/JVMs to communicate by exchaning messages and it uses a memory mapped file for the transport. The troughput has been measured to 40 million messages/s.</p>\n'}]
['https://Stackoverflow.com/questions/51452', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']