Preview:
class Display 
{ 
synchronized public void wish(String name) 
{ 
for(int i=0;i<3;i++) 
{ 
System.out.println("Good morning"); 
try 
{ 
Thread.sleep(1000); 
} 
catch(InterruptedException e) 
{} 
System.out.println(name); 
} 
} 
} 
class My extends Thread 
{ 
Display d; 
String name;
  My(Display d,String name) 

{ 

this.d=d; 

this.name=name; 

} 

public void run() 

{ 

d.wish(name); 

} 

} 

class B{ public static void main(String... args) 

{ 

Display d=new Display(); 

My t=new My(d,"Sai "); 

t.start(); 

} 

}
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