当前位置: 技术问答>java相关
帮我看看这段代码,很奇怪啊
来源: 互联网 发布时间:2015-05-05
本文导语: public class RunProspect { public RunProspect() { Thread checkSource; checkSource = new Thread() { public void run() { boolean runFlag = true; try { while(runFlag) { System.out.println("hello"); Thread.currentThread().sleep(3...
public class RunProspect
{
public RunProspect()
{
Thread checkSource;
checkSource = new Thread()
{
public void run()
{
boolean runFlag = true;
try
{
while(runFlag)
{
System.out.println("hello");
Thread.currentThread().sleep(3000);
}
}
catch(Exception e)
{
}
}
};
checkSource.start();
}
public static void main(String[] args)
{
RunProspect myProspect = new RunProspect();
//myProspect.
}
}
再命令行运行一切正常,没隔三秒打印一个hello
可是作为bean时却每隔三秒打印两个hello,很郁闷
server是weblogic
大家帮忙啊
{
public RunProspect()
{
Thread checkSource;
checkSource = new Thread()
{
public void run()
{
boolean runFlag = true;
try
{
while(runFlag)
{
System.out.println("hello");
Thread.currentThread().sleep(3000);
}
}
catch(Exception e)
{
}
}
};
checkSource.start();
}
public static void main(String[] args)
{
RunProspect myProspect = new RunProspect();
//myProspect.
}
}
再命令行运行一切正常,没隔三秒打印一个hello
可是作为bean时却每隔三秒打印两个hello,很郁闷
server是weblogic
大家帮忙啊
|
说明weblogic有对象池。。。呵呵