thread1=new Thread(this,"FirstThread");//新建立一会线程 取名字为FirstThread String currentRunning; // 声明一个字符串类型变量
while(true)
{
currentRunning=Thread.currentThread().getName();//currentThread()方法是得到当前运行的线程的名字
if(currentRunning.equals("FirstThread"))//进行判断如果当前运行的是线程1 则 count1加1
{
count1++;
threadFirst.setText("线程1第"+count1+"次被调用"); //在threadFirst控件上输出 线程1第?次被调用
}
else if(currentRunning.equals("SecondThread")) //行判断如果当前运行的是线程1 则 count2 加1
{
count2++;
threadSecond.setText("线程2第"+count2+"次被调用");
}
while(true)
{
currentRunning=Thread.currentThread().getName();//currentThread()方法是得到当前运行的线程的名字
if(currentRunning.equals("FirstThread"))//进行判断如果当前运行的是线程1 则 count1加1
{
count1++;
threadFirst.setText("线程1第"+count1+"次被调用"); //在threadFirst控件上输出 线程1第?次被调用
}
else if(currentRunning.equals("SecondThread")) //行判断如果当前运行的是线程1 则 count2 加1
{
count2++;
threadSecond.setText("线程2第"+count2+"次被调用");
}
解决方案 »
- ss2h在整合时,它们各自的版本到底是怎么选择的呢,请大神们指点一下
- jquert easyUI combotree
- 中心点构架是说,程序得所有模块都连接在中心点上,任何一个模块只和中心点有关系,其他不再有任何关系,任何一个模块必须要在中心点上,注册后,可以被中心点托管。
- 哪位高手能帮我解决下面的问题啊
- 如何将java源程序打包成jar执行文件
- 好人一生平安 30分送给您们!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 急!!计算xml文档的结点数时怎样忽略掉空白结点???在线等!!
- o.s.web.context.ContextLoader [ContextLoader.java : 308] Context initialization
- 初学JAVA,公司却要我今天写出东西,大哥大姐帮帮忙,给我一份操作数据库的源代码吧?
- spring框架测试问题大神来看看菜鸟来学学
- JSP中实现将CSV文件导入到数据库?
- 求JDOM的API文档,要免费的哦:)
非常感谢你的回答好 ..