java thread question# Java - 爪哇娇娃
d*r
1 楼
我现在正在做一个程序,遇到个问题。
我的程序是这样的:
user输入一组数,经过计算后,存到一个文件里。
因为运算的那一步比较复杂,所以user在输入一组数之后,要等一会才能输入第二组。
但是user并不需要知道结果,所以我想用threading来解决。
main thread用来接受user的输入,另一个thread(saving thread)平时处于idel。main
thread收到user
的输入后,send给saving thread。Saving thread接到main thread的message之后,开始
计算结果。
这个过程有点像http communication。但是只发生在两个thread之间。
现在问题是:
我需要一个像message pool一类的东西来存main thread发过来的message。
如果用VC的话,可以直接调用windows message queue。
如果用java怎么办呢?又没有现成的class?是在不行就只能自己写了。
我的程序是这样的:
user输入一组数,经过计算后,存到一个文件里。
因为运算的那一步比较复杂,所以user在输入一组数之后,要等一会才能输入第二组。
但是user并不需要知道结果,所以我想用threading来解决。
main thread用来接受user的输入,另一个thread(saving thread)平时处于idel。main
thread收到user
的输入后,send给saving thread。Saving thread接到main thread的message之后,开始
计算结果。
这个过程有点像http communication。但是只发生在两个thread之间。
现在问题是:
我需要一个像message pool一类的东西来存main thread发过来的message。
如果用VC的话,可以直接调用windows message queue。
如果用java怎么办呢?又没有现成的class?是在不行就只能自己写了。