IC211 Spring AY 2020
Name (Last, First): ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
t.start();
is replaced
with t.run();
? Your answer should include
Runnable
interface .
From the
API
documentation:
"A class that implements Runnable can run without
subclassing Thread by instantiating a Thread instance and
passing itself in as the target [argument to the Thread
constructor]."
Take the Example code Ex1.java/Foo.java from the "Getting data in and out" section of this lesson's notes, and rewrite it so that Foo implements Runnable rather than extending Thread.
Check to verify that you actually compiled and ran the modified code.
Write down the two lines of the program that you actually had to change to change the program to implement Runnable rather than extend Thread:
We zipped the below code up for you to download.
Point.java | Shape.java |
|
|
HW21.java | Circle.java |
|
|
Triangle.java | Rectangle.java |
|
|