Results 1 to 2 of 2

Thread: How can I print all thread states?

Threaded View

  1. #1

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    How can I print all thread states?

    The following code works fine but i am having trouble working with the Enum that is returned from getState(). In the following i guess the Enum returned will always contain just one element since a thread can only be in one state at a time.
    Code:
    public static void ThreadState(Thread t){
     Enum e = t.getState();
     System.out.println(t.getName() + " is " + e.name()); 
    }
    but how can i print out all the states? Enum defines
    Code:
    static Thread.State[] values()
    I have the following......
    Code:
    Enum e = t.getState(); 
    Thread.State[] ts = e.values();
    t is simply a Thread instance but the compiler says that e has no values() method.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width