In your constructor, you declare a local variable with a name tthat uses the same name as your field t. Just replace Thread twith this.tor just tthere:
public threadtest(String name) {
this.t=new Thread(name);
}
BTW1, it is strongly recommended that you start class names with capital letters, i.e. ThreadTestin your case would be a better name.
BTW2 worthy of an IDE will detect this error for you and draw your attention to it.
source
share