DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2006
    Posts
    1

    Question 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();
    }
    }

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    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

  1. Packed Data(Comp-3, etc)
    By Marcos in forum VB Classic
    Replies: 3
    Last Post: 01-25-2006, 11:18 AM
  2. calling ping thru vb
    By Michael Shutt in forum VB Classic
    Replies: 6
    Last Post: 04-05-2001, 02:25 AM
  3. How do I detect an FTP timeout?
    By Julian Milano in forum VB Classic
    Replies: 2
    Last Post: 08-11-2000, 12:11 PM
  4. Re: Dll function call problem - Same problem
    By Fabian in forum VB Classic
    Replies: 7
    Last Post: 06-28-2000, 12:54 PM
  5. Trying to print a PDF File from VB
    By Kunal Sharma in forum VB Classic
    Replies: 2
    Last Post: 04-25-2000, 03:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


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


Sponsored Links