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.
but how can i print out all the states? Enum definesCode:public static void ThreadState(Thread t){ Enum e = t.getState(); System.out.println(t.getName() + " is " + e.name()); }
I have the following......Code:static Thread.State[] values()
t is simply a Thread instance but the compiler says that e has no values() method.Code:Enum e = t.getState(); Thread.State[] ts = e.values();




Reply With Quote