Single vs Multi-threaded JMS Producer

后端 未结 6 1163
我寻月下人不归
我寻月下人不归 2020-12-17 04:16

I wanted to see how much time difference would it make to use a multi-threaded producer instead of a single threaded one. I setup an ActiveMQ on my local machine, wrote a pr

6条回答
  •  时光取名叫无心
    2020-12-17 04:50

    The difference you notice is very small, but I think the multi-thread processor is spending more time because the concurrency for the cpu resources between the threads. The multi-thread processor needs to share the cpu between the threads, and this may cost time and extra-processing and sometimes become your process more slow. While the single thread processor does not need to share the cpu with no other thread, it can run more efficiently. The another aspect is related to the resources used for each thread. They use only strings in memory, they don't access another resource, as disk files or databases or tcp ports. In this case, I think, single thread process will be faster than a multi thread process.

提交回复
热议问题