Advertisement
Josif_tepe

Untitled

Mar 24th, 2022
742
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.41 KB | None | 0 0
  1. public class Main {
  2.     public static void main(String[] args) {
  3.         t t1 = new t(1);
  4.         t t2 = new t(2);
  5.         t1.start();
  6.         t2.start();
  7.  }
  8. }
  9. class t extends  Thread {
  10.     int id;
  11.     public t(int _id) {
  12.         id = _id;
  13.     }
  14.     @Override
  15.     public void run() {
  16.         for(int i = 0; i < 10; i++) {
  17.             System.out.println("Thread " + id +  " " + i);
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement