Zeek_Ch13_PractiseSet1.java


/*
--> Write a code in which a thread is executed infinitely after 10 seconds of
running the code .
  */


package com.company;

class WelcomeThread extends Thread{
    public void run() {
       
        try {
            sleep(10000);   //Starts run method after 10000 milliseconds(10 seconds)
        }
        catch (Exception e) {
            System.out.println(e);  
        }
       
        while(true) {
        System.out.println("Welcome");
        }
    }
}

public class Zeek_Ch13_PractiseSet1 {
   
   

    public static void main(String[] args) {
        WelcomeThread w= new WelcomeThread();
        w.start();

    }
}

 

Comments

Popular posts from this blog

Zeek_31_MethodInJava.java