public class pres_c extends Thread { public pres_c( String to_display, int sleep_time ) { this.buf = to_display; this.sleep_time = sleep_time; } // pres_c public void run() { int last = 80 - this.buf.length(); int step = 0; while ( pres_c.keep_running ) { try { Thread.sleep( this.sleep_time ); } catch ( InterruptedException exc ) { } for ( int index = 0; index < step; index++ ) { System.out.print( " " ); } // Skriv strängen System.out.println( this.buf ); step = ( step + 1 ) % last; } } // run // Sträng att presentera // --------------------- private String buf; // Variabel för att hålla koll på // sovtid mellan presentationer // ------------------------------------ private int sleep_time; public static boolean keep_running = true; public static void main( String args[] ) { // Skapa trådar så att a-tråden körs oftare pres_c a_thread = new pres_c( "A-sträng LÅNGLÅNG", // to_display 100 ); // sleep_time pres_c b_thread = new pres_c( "B-sträng", // to_display 300 ); // sleep_time pres_c.keep_running = true; a_thread.start(); b_thread.start(); } // main } // class pres_c