Created
March 10, 2010 11:00
-
-
Save yuroyoro/327761 to your computer and use it in GitHub Desktop.
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
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