Created
March 21, 2014 08:19
-
-
Save HeinrichHartmann/9681888 to your computer and use it in GitHub Desktop.
Failing context termination on send
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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