File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
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--------
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Need help in understanding a snippet from "Thinking in Java"
 
Similar Threads
What is Mixin Classes in JavaFX?
mixin class
inner classes and encapsulation
Clarification wanted: Extending Threads vs. Implementing Runnable
Decorator Vs Java Mixin