[zeromq-dev] how to use ZeroMQ socket in multithread

Charles Remes lists at chuckremes.com
Tue May 19 14:29:32 CEST 2015


Both of those techniques are the recommended ways to use zeromq sockets in a multi-threaded application. I’m sorry that you don’t like those techniques, but they work very well.

The zmq_poll function is *not* thread-safe, so be very careful with it.


> On May 18, 2015, at 23:46, 黄颖志 <nohuangyz at gmail.com> wrote:
> 
> Yeah, the zguide says if in multithread , i should create a inporc socket per thread. but i don't want to create too much socket. Another method is to make sure each thread executes a full memory barrier before accessing the socket, in my opinion that is a hard work.
> 
> 2015-05-15 21:21 GMT+08:00 Charles Remes <lists at chuckremes.com <mailto:lists at chuckremes.com>>:
> The FAQ available here http://zeromq.org/area:faq <http://zeromq.org/area:faq> explains how to use zeromq in a multi-threaded environment.
> 
> The zguide also has good information on this topic.
> 
> cr
> 
>> On May 15, 2015, at 08:18, 张凯 <zhangkai.gis at 163.com <mailto:zhangkai.gis at 163.com>> wrote:
>> 
>> It seems zeromq can not used in multithread.But you can adjust your code with zmq_poll.
>> 
>> At 2015-05-14 20:50:23, "黄颖志" <nohuangyz at gmail.com <mailto:nohuangyz at gmail.com>> wrote:
>> Hi every body,
>>   Lastly, my J2EE project use ZeroMQ as a message system , In that project,  I want to encapsulate ZeroMQ socket as a high level API, so others could use that socket send messages if thay want . But the guide document says that ZeroMQ sockets are not thread safe.  How can I solve that problem. I don't want to create a new socket when sending some message through ZeroMQ every time. 
>> 
>> 
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org <mailto:zeromq-dev at lists.zeromq.org>
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev <http://lists.zeromq.org/mailman/listinfo/zeromq-dev>
> 
> 
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org <mailto:zeromq-dev at lists.zeromq.org>
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev <http://lists.zeromq.org/mailman/listinfo/zeromq-dev>
> 
> 
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20150519/ce2ac5ea/attachment.htm>


More information about the zeromq-dev mailing list