class Msg
{
public void Show(String name)
{
;;;;; // 100 line code
synchronized(this)
{
for(int i = 1; i <= 3; i++)
{
System.out.println("how are you " + name);
}
}
;;;;; // 100 line code
}
}
class Ourthread extends Thread
{
Msg m;
String name;
Ourthread(Msg m, String name)
{
this.m = m;
this.name = name;
}
public void run()
{
m.Show(name);
}
}
class Death
{
public static void main(String[] args)
{
Msg msg = new Msg(); // Create an instance of the Msg class
Ourthread t1 = new Ourthread(msg, "om");
Ourthread t2 = new Ourthread(msg, "harry");
t1.start();
t2.start();
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter