I have a Java program which uses ZeroMQ sockets for inter-process communication. I have thread workers that do some expensive work and as they finish their work with a result I want to pass that result object to a “sender” thread over an inproc socket, so that it can send the object to a client. I have seen examples, in C++ this is usually done using pointers, but in Java there are no pointers and I do not want to serialize the object just to be able to pass the object to another thread.
What are the possibilities that I have? I can only pass “lightweight” values to the socket, like strings or primitive types efficiently.
Thanks!
Whether you pass a reference or a pointer it is much the same. You can pass it between threads in the same process via a data structure, but you cannot pass it via a socket and expect it to work in a different process.
i.e. to pass a reference (or a pointer) between threads in the same process don’t use ZeroMQ, use something like a BlockingQueue instead.