Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TwoThreads {
- /* public static class Thread1 extends Thread {
- public void run() {
- System.out.println("A");
- System.out.println("B");
- }
- }
- public static class Thread2 extends Thread {
- public void run() {
- System.out.println("1");
- System.out.println("2");
- }
- } */
- public static class ThreadAB implements Runnable{
- Thread t;
- String s1;
- String s2;
- public ThreadAB(String string1, String string2) {
- // TODO Auto-generated constructor stub
- s1=string1;
- s2=string2;
- }
- @Override
- public void run(){
- System.out.println(s1);
- System.out.println(s2);
- }
- public void start()
- {
- run();
- }
- }
- public static void main(String[] args) {
- new ThreadAB("A","B").start();
- new ThreadAB("1","2").start();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement