• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help in understanding a snippet from "Thinking in Java"  RSS feed

Rajkumar Masanaiyan
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the below snippet, what is so convenient in having everything in the same class. Isn't it the case with classes that extend Thread?

Why is inner class being mentioned suddenly here? What is its relationship with Thread or the current context.

Note: For more context, please refer to the following URL: http://mindview.net/Books/TIJ/DownloadSites

The convenient aspect about the Runnable interface is that everything belongs to the same class; that is, Runnable allows a mixin in combination with a base class and other interfaces.

If you need to access something, you simply do it without going through a separate object.

However, inner classes have this same easy access to all the parts of an outer class, so member access is not a compelling reason to use Runnable as a mixin rather than an inner subclass of Thread.
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!