Skip to content

Instantly share code, notes, and snippets.

@yuroyoro
Created March 10, 2010 11:00
Show Gist options
  • Save yuroyoro/327761 to your computer and use it in GitHub Desktop.
Save yuroyoro/327761 to your computer and use it in GitHub Desktop.
import java.util.ArrayList;
import java.util.List;
public class OutOfMemory {
public static void main(String[] args) {
Runnable r = new Runnable() {
@Override
public void run() {
List<String> l = new ArrayList<String>();
long cnt = 0;
while (true) {
l.add(String.valueOf(cnt));
cnt++;
System.out.println(cnt);
}
}
};
Runnable r2 = new Runnable(){
@Override
public void run() {
while( true ){
System.out.println("Alive!");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
} ;
(new Thread(r)).start();
(new Thread(r2)).start();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment