Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- public class TwoThreads {
- static class ThreadAB implements Runnable
- {
- String s1;
- String s2;
- public ThreadAB(String s1,String s2)
- {
- this.s1=s1;
- this.s2=s2;
- }
- @Override
- public void run()
- {
- System.out.println(s1);
- System.out.println(s2);
- }
- }
- public static void main(String[] args) {
- ThreadAB th1=new ThreadAB("A","B");
- ThreadAB th2=new ThreadAB("1","2");
- Thread t1=new Thread(th1);
- Thread t2=new Thread(th2);
- t1.start();
- t2.start();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment