So that the run
method in the MarqueeThread
class has access
to the appropriate instance of the Marquee
class, that instance
of the Marquee
class is provided to the thread via the thread's
constructor, and is held by the marquee
instance variable.
Then, with the Marquee
instance available as the value of the
marquee
instance variable, the run
method is readily defined
to call decrementPosition
periodically.
public class MarqueeThread extends Thread { private Marquee marquee; public MarqueeThread (Marquee c) { marquee = c; } public void run () { while (true) { // Call to decrementPosition try{sleep(200);} catch (InterruptedException e) {} } } }