playthreaddownload
Thu Jan 18 2024 18:14:35 GMT+0000 (Coordinated Universal Time)
Saved by
@login
public class PlayThread extends Thread{
String songname;
public PlayThread(String tname,String songname){
super(tname);
this.songname=songname;
}
public void run(){
System.out.println("In Thread-"+this.getName());
for(int i=1;i<=10;i++){
System.out.println("Playing"+songname);
}
System.out.println("Done Playing");
}
}
public class Download extends Thread {
String songname;
public Download(String dname,String songname){
super(dname);
this.songname=songname;
}
public void run(){
System.out.println("In Thread-"+this.getName());
for(int i=1;i<=10;i++){
System.out.println("Downloading"+songname);
}
System.out.println("Downloaded");
}
}
public class Main {
public static void main(String[] args) {
System.out.println("In Main Thread");
PlayThread t1=new PlayThread("Play-Thread", "song-1");
Download t2=new Download("Downloading Thread", "song-1");
t1.start();
t2.start();
System.out.println("DONE");
}
}
content_copyCOPY
Comments