package verwaltung; /* * Created on Jul 5, 2004 */ /** * @author oliver * @since Jul 5, 2004 */ public class Person implements Runnable { public String name; private int alter; // folgendes Attribute sollte eine Warnung zur Folge haben private java.sql.Date geboren = new java.sql.Date(0); public Person(String name) { this.name = name; //java.sql.DriverManager.getLogWriter(); } public void setName(String name) { this.name = name; } public void setAlter(int i) { this.alter = i; } public String getName() { return this.name; } public String toString() { return this.name; } public void run() { arbeite(); } public void arbeite() { System.out.println(this.getName() + " stempelt ein."); try { Thread.sleep(3000); } catch (InterruptedException e) { System.err.println("beim Schlafen gestoert\n" + e); } System.out.println(this.getName() + " stempelt aus."); } public static void main(String[] args) throws InterruptedException { Person[] team = { new Person("Asterix"), new Person("Obelix"), new Person("Majestix") }; team[1].setName("Idefix"); for (int i = 0; i < team.length; i++) { Thread thread = new Thread(team[i]); thread.start(); Thread.sleep(1000); // wait a second } } }