Advertisement
salercode

Lab2OsZad1

Mar 10th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.*;
  3. public class TwoThreads {
  4.  
  5.     static class ThreadAB implements Runnable
  6.     {
  7.         String s1;
  8.         String s2;
  9.         public ThreadAB(String s1,String s2)
  10.         {
  11.             this.s1=s1;
  12.             this.s2=s2;
  13.         }
  14.         @Override
  15.         public void run()
  16.         {
  17.             System.out.println(s1);
  18.             System.out.println(s2);
  19.         }
  20.  
  21.     }
  22.  
  23.  
  24.     public static void main(String[] args) {
  25.         ThreadAB th1=new ThreadAB("A","B");
  26.         ThreadAB th2=new ThreadAB("1","2");
  27.         Thread t1=new Thread(th1);
  28.         Thread t2=new Thread(th2);
  29.         t1.start();
  30.         t2.start();
  31.     }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement