课程: Java: Advanced Concepts for High-Performance Development

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

The Runnable interface in Java

The Runnable interface in Java

- [Instructor] Now I have a class that extends the thread class called ThreadExample. So let's have a closer look at this thread class itself. If I right click on the class and I go to, Go To and then declaration or usages, this actually takes me to the source code for the class. So I can see that class actually implements another class called runnable. So let's have a look at that one as well. So I'm going to right click and say Go To declaration or usages. So Runnable is actually a functional interface and it defines a single method called Run. So if I go back to my ThreadExample class I can see that I'm actually overriding this run method from the Runnable interface. This class doesn't actually override anything else from the thread class. So one thing I could do is I could actually override the Runnable interface rather than extend the thread class. One advantage of doing this is that if I extend the thread class…

内容