:
public int countStackFrame() always returns the number of stack frames
regardless of the thread status (suspended or unsuspended).
---code----
class runitforever implements Runnable {
public void run() {
while ( true ) {
System.out.println("run it?");
if (Math.random() < 0.77)
// yield to others sometimes
Thread.yield();
try {
Thread.currentThread().countStackFrames();
} catch ( IllegalStateException test_e) {
//exception_count++;
System.out.println("IllegalStaeException thrown by countStackFrame() is caught");
}
}
}
}
class threadtest03 {
public static void main( String args[] ) {
runitforever rt = new runitforever();
Thread pt = new Thread(rt);
pt.start();
Thread.sleep(100);
//countStackFrames() when it is not suspended
try {
if ( pt.countStackFrames() > 0 ) System.out.println("ok");
} catch ( IllegalStateException test_e) {
exception_count++;
System.out.println("IllegalStaeException thrown by countStackFrame() is aught");
}
}
public int countStackFrame() always returns the number of stack frames
regardless of the thread status (suspended or unsuspended).
---code----
class runitforever implements Runnable {
public void run() {
while ( true ) {
System.out.println("run it?");
if (Math.random() < 0.77)
// yield to others sometimes
Thread.yield();
try {
Thread.currentThread().countStackFrames();
} catch ( IllegalStateException test_e) {
//exception_count++;
System.out.println("IllegalStaeException thrown by countStackFrame() is caught");
}
}
}
}
class threadtest03 {
public static void main( String args[] ) {
runitforever rt = new runitforever();
Thread pt = new Thread(rt);
pt.start();
Thread.sleep(100);
//countStackFrames() when it is not suspended
try {
if ( pt.countStackFrames() > 0 ) System.out.println("ok");
} catch ( IllegalStateException test_e) {
exception_count++;
System.out.println("IllegalStaeException thrown by countStackFrame() is aught");
}
}
- duplicates
-
JDK-4056771 JDK 1.1.2 countStackFrames() doesn't throw IllegalThreadStateException
-
- Closed
-
-
JDK-4102667 Thread.countStackFrames() should be a deprecated method.
-
- Closed
-