Advertisement
ivana_andreevska

Thread vtor del so materijali od predavanje

Mar 7th, 2022
1,657
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. import java.io.*;
  2. import java.io.File;
  3.  
  4. public class Main
  5. {
  6.     public static void main(String[] args) {
  7.         //System.out.println("Execution into the main class");
  8.  
  9.         ThreadClass t1=new ThreadClass("T1");
  10.         ThreadClass t2=new ThreadClass("T2");
  11.         t1.start();
  12.         t2.start();
  13.        
  14.         //se ozvrsuvaat naizmenicno bidjeki rabotat vo odredeni time slotovi
  15.     }
  16. }
  17. class ThreadClass extends Thread
  18. {
  19.     String name;
  20.     public ThreadClass(String name)
  21.     {
  22.         this.name=name;
  23.     }
  24.     @Override
  25.     public void run() {
  26.         System.out.println("Ececution in the thread");
  27.  
  28.         for(int i=0;i<20;i++)
  29.         {
  30.             System.out.println("Thread: "+name+": "+ i);
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement