-
printStackTrace function problem
hi all,
I am trying to compile following code but getting error.
Can you please let me know what is the problem with following code?
import java.lang.Runnable;
import java.lang.Thread;
/**
*
* @author vaibhavc
*/
public class MyThread implements Runnable{
/** Creates a new instance of MyThread */
public MyThread() {
}
public void run(){
System.out.println("Method called");
System.out.println(printStackTrace());
}
public static void main (String[] args){
Thread main_thread = Thread.currentThread();
Thread.currentThread().printStackTrace();
Thread t = new Thread(new MyThread());
t.start();
}
}
-
What error message are you seeing? Does it have anything to do with the method currentThread not having a method printStackTrace? You need to allow the compiler to know that your priority is to have the Thread.currentThread method to return a Thread object, whose printStackTrace method will be called. Help the compiler with your priority by using parenthesis:
(Thread.currentThread()).printStackTrace();
Similar Threads
-
By Marcos in forum VB Classic
Replies: 3
Last Post: 01-25-2006, 11:18 AM
-
By Michael Shutt in forum VB Classic
Replies: 6
Last Post: 04-05-2001, 02:25 AM
-
By Julian Milano in forum VB Classic
Replies: 2
Last Post: 08-11-2000, 12:11 PM
-
By Fabian in forum VB Classic
Replies: 7
Last Post: 06-28-2000, 12:54 PM
-
By Kunal Sharma in forum VB Classic
Replies: 2
Last Post: 04-25-2000, 03:45 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks