代码:
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环境下编译、运行都正常。新手上路,请多多指教。谢谢!!

解决方案 »

  1.   

    代码输出正常啊,没问题。。
    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
      

  2.   

    谢谢楼上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的版本或设置有关系呢。