Skip to Main Content
Operating Systems: Concurrent and Distributed Software Design
book

Operating Systems: Concurrent and Distributed Software Design

by Jean Bacon, Tim Harris
March 2003
Intermediate to advanced content levelIntermediate to advanced
912 pages
27h 17m
English
Pearson Business
Content preview from Operating Systems: Concurrent and Distributed Software Design

4.18. Java threads and exceptions

In Java, threads are created from a class which either inherits from the class Thread or implements the interface Runnable. In either case we specify the activity to be carried out by providing a run method. In the case of a thread inheriting from the Thread class, the run method overrides the run method of Thread, which otherwise has an empty method body. Producing threads via the mechanism of implementing the interface Runnable allows us to produce a class which can be used to create threads whilst still being able to inherit from some class other than Thread. Java only has single inheritance.

The program in Figure 4.32 explicitly creates two threads, using a thread that specializes Thread. The program in ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Principles of Concurrent and Distributed Programming, Second Edition

Principles of Concurrent and Distributed Programming, Second Edition

M. Ben-Ari
Operating Systems in Depth

Operating Systems in Depth

Thomas W. Doeppner

Publisher Resources

ISBN: 0321117891Purchase book