java.lang.Thread
Thread(ThreadGroup group,Runnable target,String name,long stackSize)
jdk1.4 build50
When I give stackSize =0 the test program pass on solaris and winNT.
When I give stackSize =(long)100 test program pass on winNT and
on solaris Segmentation Fault (core dumped).
--------------Test program----------------------------
// java.lang.Thread Thread(ThreadGroup group,Runnable target,String name,long stackSize)
public class Test implements Runnable {
private static long stackSize =(long)100;
private static int recursiveDepth =10;
private static int noOfThreads = 1;
private static ThreadGroup group = new ThreadGroup("test2");
public static void main(String []args) {
try {
Test test = new Test();
Thread [] thread = new Thread[noOfThreads];
for (int i =0; i <noOfThreads; i++) {
String name = "threadTest" + i;
thread[i] = new Thread(group, test,name,stackSize);
thread[i].start();
}
System.out.println("Thread.activeCount = " + Thread.activeCount());
Thread.sleep(1000);
System.out.println("Threads activeCount = " + Thread.activeCount());
} catch (Exception e) {
System.out.println("exception thrown " +e);
}
System.out.println("Test() Pass");
}
public void run() {
System.out.println("I am in run");
recursive(1);
}
void recursive(int i) {
i = i +1;
try {
if (i <recursiveDepth) {
System.out.println("I am in recursive i = " + i);
recursive(i);
}
} catch(Exception e) {
System.out.println(e);
}
}
}
Thread(ThreadGroup group,Runnable target,String name,long stackSize)
jdk1.4 build50
When I give stackSize =0 the test program pass on solaris and winNT.
When I give stackSize =(long)100 test program pass on winNT and
on solaris Segmentation Fault (core dumped).
--------------Test program----------------------------
// java.lang.Thread Thread(ThreadGroup group,Runnable target,String name,long stackSize)
public class Test implements Runnable {
private static long stackSize =(long)100;
private static int recursiveDepth =10;
private static int noOfThreads = 1;
private static ThreadGroup group = new ThreadGroup("test2");
public static void main(String []args) {
try {
Test test = new Test();
Thread [] thread = new Thread[noOfThreads];
for (int i =0; i <noOfThreads; i++) {
String name = "threadTest" + i;
thread[i] = new Thread(group, test,name,stackSize);
thread[i].start();
}
System.out.println("Thread.activeCount = " + Thread.activeCount());
Thread.sleep(1000);
System.out.println("Threads activeCount = " + Thread.activeCount());
} catch (Exception e) {
System.out.println("exception thrown " +e);
}
System.out.println("Test() Pass");
}
public void run() {
System.out.println("I am in run");
recursive(1);
}
void recursive(int i) {
i = i +1;
try {
if (i <recursiveDepth) {
System.out.println("I am in recursive i = " + i);
recursive(i);
}
} catch(Exception e) {
System.out.println(e);
}
}
}