Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Object o = new Object();
- Thread t1 = new Thread() {
- public void run() {
- synchronized(o) {
- for(int i=0; i<1000; i++) {
- System.out.print(" " +i+ " AAAA");
- // System.out.println(" letif");
- }
- System.out.println("");
- }
- }
- };
- Thread t2 = new Thread() {
- public void run() {
- synchronized(o) {
- for(int i=0; i<1000; i++) {
- System.out.print(" " +i+ " BBBB");
- // System.out.println(" letif");
- }
- System.out.println("");
- }
- }
- };
- try {
- t1.start();
- t1.join();
- t2.start();
- t2.join();
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement