• Post Reply Bookmark Topic Watch Topic
  • New Topic

Anonymous inner class?  RSS feed

 
Shubham Semwal
Ranch Hand
Posts: 176
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


How can this thing possiblt start a thread ??
 
Dieter Quickfend
Bartender
Posts: 543
4
Java Netbeans IDE Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thread object needs a Runnable to start, you pass it a Runnable object and a thread name, and tell the Thread object to start, which causes the Thread object to start the thread. I don't see the issue here.
 
Stephan van Hulst
Saloon Keeper
Posts: 7719
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would it help if it looked like this?
What happens here is exactly the same as what happens in your code, except that the thread and the task get assigned to a variable in between.
 
Shubham Semwal
Ranch Hand
Posts: 176
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:Would it help if it looked like this?
What happens here is exactly the same as what happens in your code, except that the thread and the task get assigned to a variable in between.


Yeah now i understood.. that was horrible formatting ..
But still my code doesn't have any ; denoting the end of anonymous class ..
 
Stephan van Hulst
Saloon Keeper
Posts: 7719
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't end classes with a semi-colon, you end statements with them. Assigning the anonymous instance to a variable is a statement. In your code the instance is being passed directly to the Thread constructor.
 
Shubham Semwal
Ranch Hand
Posts: 176
3
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:You don't end classes with a semi-colon, you end statements with them.


Omg.. That's a century's worth of wisdom
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!