Question: Write the java code for the following problem. class myThread implements Runnable { public void run ( ) { Test.obj.notify ( ) ; } }

Write the java code for the following problem.
class myThread implements Runnable
{
public void run()
{
Test.obj.notify();
}
}
public class Test implements Runnable
{
public static Test obj;
private int data;
public Test()
{
data =10;
}
public void run()
{
obj = new Test();
obj.wait();
obj.data +=20;
System.out.println(obj.data);
}
public static void main(String[] args) throws InterruptedException
{
Thread thread1= new Thread(new Test());
Thread thread2= new Thread(new myThread());
thread1.start();
thread2.start();
System.out.printf(" GFG -");
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!