Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java multithreading

//Using Thread Class
public class MultiThreadinng extends Thread{
    public static void main(String[] args) throws InterruptedException{
        MultiThreadinng mt = new MultiThreadinng();
        mt.start();
        for(int j=0; j<200; j++){
            System.out.print("j: "+ j+"	");

            Thread.sleep(1000);
        }
    }

    public void run(){
        for(int i=0; i<200; i++){
            System.out.print("i: "+ i+"	");

                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }


        }
    }
}
 
PREVIOUS NEXT
Tagged: #java #multithreading
ADD COMMENT
Topic
Name
5+9 =