eclipse 运行多线程问题

Nuc_sun 2009-08-07 03:15:24
代码:
package p08;

import java.util.Date;

public class Example8 {

/**
* @param args
*/

static AThread threadA;
static BThread threadB;
public static void main(String[] args) {
// TODO 自动生成方法存根
threadA = new AThread();
threadB = new BThread();

threadA.start();
threadB.start();
}

}

class AThread extends Thread {
public void run()
{
Date timeNow;
for(int i=0;i<=5;i++)
{
timeNow = new Date();
System.out.println("I am thread A:" + timeNow.toString());
try
{
sleep(2000);
}
catch(Exception e){}
}
}
}

class BThread extends Thread {
public void run()
{
Date timeNow;
for(int i=0;i<=5;i++)
{
timeNow = new Date();
System.out.println("I am thread B:" + timeNow.toString());
try
{
sleep(1000);
}
catch(Exception e){}
}
}
}

运行后控制台提示:
属性未被指定且 ExecPermissions/ExecOptionPermissions
均未被授权。随后的激活尝试失败,原因是对
ExecPermission/ExecOptionPermission 的权限检查失败。 有关如何
配置 rmid 安全性的文档说明,请参阅:

http://java.sun.com/j2se/1.4/docs/tooldocs/solaris/rmid.html
http://java.sun.com/j2se/1.4/docs/tooldocs/win32/rmid.html

但纳闷的是,再dos环境下编译、运行都正常。

新手上路,请多多指教。谢谢!!
...全文
225 3 打赏 收藏 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Nuc_sun 2009-08-10
  • 打赏
  • 举报
回复
谢谢楼上2位!!

我又运行了一次,控制台也提示:
属性未被指定且 ExecPermissions/ExecOptionPermissions
均未被授权。随后的激活尝试失败,原因是对
ExecPermission/ExecOptionPermission 的权限检查失败。 有关如何
配置 rmid 安全性的文档说明,请参阅:

http://java.sun.com/j2se/1.4/docs/tooldocs/solaris/rmid.html
http://java.sun.com/j2se/1.4/docs/tooldocs/win32/rmid.html

不过第二次再运行,可以了。真不知道咋回事,这是否与eclipse的版本或设置有关系呢。
yubangqi 2009-08-07
  • 打赏
  • 举报
回复
什么问题?我试过,一切正常
flyinghawl 2009-08-07
  • 打赏
  • 举报
回复
代码输出正常啊,没问题。。。。。
I am thread A:Fri Aug 07 18:17:52 CST 2009
I am thread B:Fri Aug 07 18:17:52 CST 2009
I am thread B:Fri Aug 07 18:17:53 CST 2009
I am thread A:Fri Aug 07 18:17:54 CST 2009
I am thread B:Fri Aug 07 18:17:54 CST 2009
I am thread B:Fri Aug 07 18:17:55 CST 2009
I am thread A:Fri Aug 07 18:17:56 CST 2009
I am thread B:Fri Aug 07 18:17:56 CST 2009
I am thread B:Fri Aug 07 18:17:57 CST 2009
I am thread A:Fri Aug 07 18:17:58 CST 2009
I am thread A:Fri Aug 07 18:18:00 CST 2009
I am thread A:Fri Aug 07 18:18:02 CST 2009

62,620

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧