Reputation: 3
I have written this code and this generate the error like Illegal start of expression on the line of run() method ,please solve my problem.
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();
}
}
Upvotes: 0
Views: 43
Reputation: 695
Change your code,
{ public void run(){ m();//calling method of Reentrant class } };
to
public void run(){
m();//calling method of Reentrant class
}
Upvotes: 1