Thread类

1.获取当前类方法

Thread.currentThread().getStackTrace()[1].getClassName();

 

getStackTrace()方法介绍

/**
 * Returns an array of stack trace elements representing the stack dump
 * of this thread.  This method will return a zero-length array if
 * this thread has not started, has started but has not yet been
 * scheduled to run by the system, or has terminated.
 * If the returned array is of non-zero length then the first element of
 * the array represents the top of the stack, which is the most recent
 * method invocation in the sequence.  The last element of the array
 * represents the bottom of the stack, which is the least recent method
 * invocation in the sequence.
 *
 * <p>If there is a security manager, and this thread is not
 * the current thread, then the security manager's
 * <tt>checkPermission</tt> method is called with a
 * <tt>RuntimePermission("getStackTrace")</tt> permission
 * to see if it's ok to get the stack trace.
 *
 * <p>Some virtual machines may, under some circumstances, omit one
 * or more stack frames from the stack trace.  In the extreme case,
 * a virtual machine that has no stack trace information concerning
 * this thread is permitted to return a zero-length array from this
 * method.
 *
 * @return an array of <tt>StackTraceElement</tt>,
 * each represents one stack frame.
 *
 * @throws SecurityException
 *        if a security manager exists and its
 *        <tt>checkPermission</tt> method doesn't allow
 *        getting the stack trace of thread.
 * @see SecurityManager#checkPermission
 * @see RuntimePermission
 * @see Throwable#getStackTrace
 *
 * @since 1.5
 */

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值