classCodeaftextendsThread{publicvoidrun(){for(inti=100;i<=105;i++){try{Thread.sleep(500);}catch(Exceptione){System.out.println(e);}System.out.print(i+" ");}System.out.println("\n———————————————————————————————————————————");}publicstaticvoidmain(Stringargs[]){System.out.println("———————————————————————————————————————————");System.out.println("Implementation of Java multithreading");System.out.println("———————————————————————————————————————————");Codeaftt1=newCodeaft();Codeaftt2=newCodeaft();t1.start();try{t1.join(500);}catch(Exceptione){System.out.println(e);}t2.start();}}
Dear User, Thank you for visitng Codeaft. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.