Skip to content

Instantly share code, notes, and snippets.

@deximat
Created August 28, 2015 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deximat/e88afe9f34880466aa73 to your computer and use it in GitHub Desktop.
Save deximat/e88afe9f34880466aa73 to your computer and use it in GitHub Desktop.
When will it stop?
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