Choosing an Approach , Java Help

Choosing an Approach 

 At this point, you .might be wondering why Java has two ways to create child .threads and which approach is better. The answers to these questions turn on the same point.

 The Thread class defines several methods that can be overridden by a derived class. Of these methods, the only one that must be overridden is run( ). This is, of course, the , same method required when you implement Runnable. Many Java programmers feel that classes 'should be extended only when they are being enhanced or modified some way. So, if you will not be overriding any of Thread's other methods, it is probably best simply to implement Runnable. This is up to you, of course. However, throughout the rest of this chapter, we will create threads by using classes that implement Runnable.

Posted on September 17, 2014 in The Complete Reference

Share the Story

About the Author

Back to Top
Share This