• Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread  RSS feed

 
meeta gaur
Ranch Hand
Posts: 305
Notepad Tomcat Server Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Test.java:4: error: cannot find symbol
interrupt();
^
symbol: method interrupt()
location: class Test
Test.java:6: error: cannot find symbol
System.out.println(isAlive());
^
symbol: method isAlive()
location: class Test
2 errors

But if i don't implement Runnable and i do extends Thread then it works fine
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right: Test is not a Thread, it is a Runnable, so you can't access methods that are part of Thread. A Thread is what gets created in line 11:
 
meeta gaur
Ranch Hand
Posts: 305
Notepad Tomcat Server Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be implementing Runnable, not extending Thread. If you want to perform operations on the current Thread, you can call Thread.currentThread().
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!