Skip to content

Instantly share code, notes, and snippets.

@HeinrichHartmann
Created March 21, 2014 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HeinrichHartmann/9681888 to your computer and use it in GitHub Desktop.
Save HeinrichHartmann/9681888 to your computer and use it in GitHub Desktop.
Failing context termination on send
import org.zeromq.ZMQ;
import org.zeromq.ZMQException;
public class TermOnSend {
public static void main(String[] args) {
final ZMQ.Context ctx = ZMQ.context(1);
Thread threadB = new Thread(new Runnable() {
@Override
public void run() {
ZMQ.Socket socket = ctx.socket(ZMQ.PUSH);
try {
socket.send("Some message"); // blocks
} catch (ZMQException e) {
socket.setLinger(0); // throws zmq.ZError$CtxTerminatedException
socket.close();
}
}
});
threadB.start();
// give thread B some time to start up
try {
Thread.sleep(20);
} catch (InterruptedException e) {
e.printStackTrace();
}
ctx.term(); // blocks and does not return
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment