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{
- char prv;
- char vtor;
- public ThreadAB(char prv,char vtor){
- this.prv=prv;
- this.vtor=vtor;
- }
- @Override
- public void run() {
- System.out.println(prv);
- System.out.println(vtor);
- }
- }
- public static void main(String[] args) throws InterruptedException {
- Thread t1=new Thread(new ThreadAB('A','B'));
- Thread t2=new Thread(new ThreadAB('1','2'));
- t1.start();
- t1.join();
- t2.start();
- t2.join();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement