我已经编写了这段代码,这会在run()方法的行上生成错误的表达式开头,请解决我的问题。
class Reentrant
{
public synchronized void m()
{
n();
System.out.println("this is m() method");
}
public synchronized void n()
{
System.out.println("this is n() method");
}
{
public void run(){
m();//calling method of Reentrant class
}
};
}
class ReentrantExample
{
public static void main(String args[])
{
Reentrant re=new Reentrant();
Thread t1=new Thread();
t1.start();
}
}
答案 0 :(得分:1)
更改代码,
{ public void run(){ m();//calling method of Reentrant class } };
到
public void run(){
m();//calling method of Reentrant class
}