< prev index next >

src/java.base/share/classes/java/lang/Thread.java

Print this page




1234      * <p> An application might use the {@linkplain #activeCount activeCount}
1235      * method to get an estimate of how big the array should be, however
1236      * <i>if the array is too short to hold all the threads, the extra threads
1237      * are silently ignored.</i>  If it is critical to obtain every active
1238      * thread in the current thread's thread group and its subgroups, the
1239      * invoker should verify that the returned int value is strictly less
1240      * than the length of {@code tarray}.
1241      *
1242      * <p> Due to the inherent race condition in this method, it is recommended
1243      * that the method only be used for debugging and monitoring purposes.
1244      *
1245      * @param  tarray
1246      *         an array into which to put the list of threads
1247      *
1248      * @return  the number of threads put into the array
1249      *
1250      * @throws  SecurityException
1251      *          if {@link java.lang.ThreadGroup#checkAccess} determines that
1252      *          the current thread cannot access its thread group
1253      */
1254     public static int enumerate(Thread tarray[]) {
1255         return currentThread().getThreadGroup().enumerate(tarray);
1256     }
1257 
1258     /**
1259      * Counts the number of stack frames in this thread. The thread must
1260      * be suspended.
1261      *
1262      * @return     the number of stack frames in this thread.
1263      * @throws     IllegalThreadStateException  if this thread is not
1264      *             suspended.
1265      * @deprecated The definition of this call depends on {@link #suspend},
1266      *             which is deprecated.  Further, the results of this call
1267      *             were never well-defined.
1268      *             This method is subject to removal in a future version of Java SE.
1269      * @see        StackWalker
1270      */
1271     @Deprecated(since="1.2", forRemoval=true)
1272     public native int countStackFrames();
1273 
1274     /**




1234      * <p> An application might use the {@linkplain #activeCount activeCount}
1235      * method to get an estimate of how big the array should be, however
1236      * <i>if the array is too short to hold all the threads, the extra threads
1237      * are silently ignored.</i>  If it is critical to obtain every active
1238      * thread in the current thread's thread group and its subgroups, the
1239      * invoker should verify that the returned int value is strictly less
1240      * than the length of {@code tarray}.
1241      *
1242      * <p> Due to the inherent race condition in this method, it is recommended
1243      * that the method only be used for debugging and monitoring purposes.
1244      *
1245      * @param  tarray
1246      *         an array into which to put the list of threads
1247      *
1248      * @return  the number of threads put into the array
1249      *
1250      * @throws  SecurityException
1251      *          if {@link java.lang.ThreadGroup#checkAccess} determines that
1252      *          the current thread cannot access its thread group
1253      */
1254     public static int enumerate(Thread[] tarray) {
1255         return currentThread().getThreadGroup().enumerate(tarray);
1256     }
1257 
1258     /**
1259      * Counts the number of stack frames in this thread. The thread must
1260      * be suspended.
1261      *
1262      * @return     the number of stack frames in this thread.
1263      * @throws     IllegalThreadStateException  if this thread is not
1264      *             suspended.
1265      * @deprecated The definition of this call depends on {@link #suspend},
1266      *             which is deprecated.  Further, the results of this call
1267      *             were never well-defined.
1268      *             This method is subject to removal in a future version of Java SE.
1269      * @see        StackWalker
1270      */
1271     @Deprecated(since="1.2", forRemoval=true)
1272     public native int countStackFrames();
1273 
1274     /**


< prev index next >