The moose likes Threads and Synchronization and the fly likes Need help in understanding a snippet from Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "Need help in understanding a snippet from "Thinking in Java"" Watch "Need help in understanding a snippet from "Thinking in Java"" New topic
Author

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

Rajkumar Masanaiyan
Greenhorn

Joined: Sep 17, 2011
Posts: 24
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

--------snip--------
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.
--------snip--------
 
IntelliJ Java IDE
 
subject: Need help in understanding a snippet from "Thinking in Java"
 
Threads others viewed
Clarification wanted: Extending Threads vs. Implementing Runnable
mixin class
Decorator Vs Java Mixin
What is Mixin Classes in JavaFX?
inner classes and encapsulation
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture