mirror of
https://github.com/corda/corda.git
synced 2025-01-14 16:59:52 +00:00
add TestThreads.java
This commit is contained in:
parent
db529925e2
commit
d3735e9e58
45
classpath/TestThreads.java
Normal file
45
classpath/TestThreads.java
Normal file
@ -0,0 +1,45 @@
|
||||
public class TestThreads {
|
||||
|
||||
public static void main(String[] args) {
|
||||
TestThreads test = new TestThreads();
|
||||
Thread th = new Thread(test);
|
||||
|
||||
try {
|
||||
synchronized (test) {
|
||||
th.start();
|
||||
test.wait();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println("finished");
|
||||
}
|
||||
|
||||
public void run() {
|
||||
synchronized (this) {
|
||||
int i = 0;
|
||||
try {
|
||||
System.out.println("I'm running in a seperate thread!");
|
||||
|
||||
final int arrayCount = 64;
|
||||
final int arraySize = 4;
|
||||
System.out.println("Allocating and discarding " + arrayCount +
|
||||
" arrays of " + arraySize + "MB each");
|
||||
for (; i < arrayCount; ++i) {
|
||||
byte[] array = new byte[arraySize * 1024 * 1024];
|
||||
}
|
||||
|
||||
long nap = 5;
|
||||
System.out.println("sleeping for " + nap + " seconds");
|
||||
Thread.sleep(nap * 1000);
|
||||
} catch (Throwable e) {
|
||||
System.err.println("caught something in second thread after " + i +
|
||||
" iterations");
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user