Created
August 28, 2015 17:16
-
-
Save deximat/e88afe9f34880466aa73 to your computer and use it in GitHub Desktop.
When will it stop?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
Vector<Integer> v1 = new Vector<>(); | |
Vector<Integer> v2 = new Vector<>(); | |
Thread t1 = new Thread(new Runnable() { | |
@Override | |
public void run() { | |
int i = 0; | |
while(true) { | |
System.out.println("T1 try" + i); | |
v1.addAll(v2); | |
i++; | |
} | |
} | |
}); | |
Thread t2 = new Thread(new Runnable() { | |
public void run() { | |
int i = 0; | |
while(true) { | |
System.out.println("T2 try " + i); | |
v2.addAll(v1); | |
i++; | |
} | |
} | |
}); | |
t1.start(); | |
t2.start(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment