/** * Copyright (c): Uwe Schmidt, FH Wedel * * You may study, modify and distribute this source code * FOR NON-COMMERCIAL PURPOSES ONLY. * This copyright message has to remain unchanged. * * Note that this document is provided 'as is', * WITHOUT WARRANTY of any kind either expressed or implied. */ /** * eine einfache Klasse * mit Runnable interface */ //-------------------- public class SimpleRunnable implements Runnable { //-------------------- public SimpleRunnable() { } //-------------------- public void run() { for (int i = 1; i <= 10; ++i ) { System.out.println(Thread.currentThread().getName() + " the " + i + ". time"); doSomething(); } System.out.println(Thread.currentThread().getName() + " finished"); } //-------------------- public void doSomething() { try { // really doing something ??? Thread.currentThread() .sleep( (int)(Math.random() * 500) ); } catch ( InterruptedException e ) { } } } //--------------------