线程 - java 进程通信问题
伊谢尔伦
伊谢尔伦 2017-04-18 10:33:14
0
2
350

现在有这样一个场景。

有一个jar在多线程运行,每个线程里都有自己的局部变量累加器 long count;

现在我需要通过一个spring的web project获取每个线程的count值,并且通过highcharts绘制出图形

请问这个独立jar的各自线程中的count局部变量,如何能被spring拿到?

自己想到的几个方法:

1.NIO的管道通信,PipedInputStream、PipedOutputStream

2.Thrift RPC服务

3.netty的服务

有没有可行的解决方案?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(2)
黄舟

According to my understanding, you need inter-process communication, right?
Thrift and Netty you mentioned are both acceptable.
Or you can also use a message queue. Each jar package acts as a producer and submits count as a message to the queue, and then Your Spring Web project can retrieve the count value from the queue.

巴扎黑

No need.
Get data directly from count使用map结构存放在redis中就ok了。hightcharts渲染时直接从redis.
The structure is as follows.

counter
    |
    | key1: v1`
    | key2: v2
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!