/** * Echo class displays the given character c * exactly n times */ public class Echo implements Runnable { private char c; private int n; // Constructor public Echo( char c, int n ) { this.c = c; this.n = n; } // Must implement the run() method public void run() { for ( int i = 0 ; i < n ; i++ ) { System.out.print( c ); // Calling yield() reliniquishes control // to another runnable thread // Thread.yield(); } } }