Advertisement
Strade351

Conveer

Sep 13th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.53 KB | None | 0 0
  1. /**
  2.  * Created by Anatoliy on 13.09.2016.
  3.  */
  4.  
  5. public class Conveer extends Thread {
  6.     public Conveer(String name) {
  7.         super(name);
  8.     }
  9.  
  10.     public void run() {
  11.         if (getName().equals("Type 1")) {
  12.             for (int i = 0; i < 50; i++) {
  13.                 System.out.println(getName() + " " + i);
  14.                 try {
  15.                     sleep(100);
  16.                 }
  17.  
  18.                 catch (InterruptedException e) {
  19.                     e.printStackTrace();
  20.                 }
  21.             }
  22.         }
  23.  
  24.         if (getName().equals("Type 2")) {
  25.             for (int i = 0; i < 100; i++) {
  26.                 System.out.println(getName() + " " + i);
  27.                 try {
  28.                     sleep(200);
  29.                 }
  30.  
  31.                 catch (InterruptedException e) {
  32.                     e.printStackTrace();
  33.                 }
  34.             }
  35.         }
  36.  
  37.         if (getName().equals("Type 3")) {
  38.             for (int i = 0; i < 20; i++) {
  39.                 System.out.println(getName() + " " + i);
  40.                 try {
  41.                     sleep(300);
  42.                 }
  43.  
  44.                 catch (InterruptedException e) {
  45.                     e.printStackTrace();
  46.                 }
  47.             }
  48.         }
  49.     }
  50.  
  51.     public static void main(String[] args) {
  52.         Conveer conveer = new Conveer("Type 1");
  53.         Conveer conveer2 = new Conveer("Type 2");
  54.         Conveer conveer3 = new Conveer("Type 3");
  55.  
  56.         conveer.start();
  57.         conveer2.start();
  58.         conveer3.start();
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement