This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / 新手,请问大侠们,JAVA中两个THREAD间如何交换数据,通过什么机制?比如一个在前台,一个在后台,怎样将后台程序中数据变化实时反应到前台界面,需要前台程序不断的POLLING吗?还是有比较SMART的方法?
-satine(satine);
2002-3-21
(#413586@0)
-
static array
-cairb(Ruibo);
2002-3-22
(#413901@0)
-
XML-RPC
-rolia123(123);
2002-3-22
(#414166@0)
-
Use pipe. e.g: create a class Pipe with method: isHasNewThing, pullInfo,addInfo; inside use a queue. Send the instance of Pipe to both Thread. I remember there is a stream can do it as well ...Reader:
while (true)
{
if (pipe.isHasNewThing())
{
Information = pullinfo();
}
sleep(forAwhile);
}
-ra95(忘忧草);
2002-3-22
{106}
(#414395@0)