knowing the caller object or thread from static method

I have a static method of a class and which is being called from another non static method from an object or thread.
Is there a way to know that from which thread or object it was called?
I think it's not possible and I need it for nothing, but just want to confirm it. I mean something like this class CallerID { public static void main(String ...s) { CallerID ob=new CallerID(); ob.caller(); } void caller() { showCaller(); System.out.println("In this method, ob = "+this); } static void showCaller() { //code to get caller object ob like it is printed in method caller() } }
So, do you want the calling object, or the current thread? Those are completely different things. Thread.currentThread() returns the current thread.

以上就是knowing the caller object or thread from static method的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准