/**
* A printer prints its name 1000 times.
*
* @author Franck van Breugel
*/
public class Printer extends Thread
{
/**
* Initializes this printer with the given name.
*
* @param name the name of this printer.
* @pre. name != null
*/
public Printer(String name)
{
super(name);
}
/**
* Prints the name of this printer 1000 times.
*/
public void run()
{
final int NUMBER = 1000;
for (int i = 0; i < NUMBER; i++)
{
System.out.print(this.getName());
}
}
}
public class PrinterTest
{
public static void main(String[] args)
{
new Printer("1").start();
new Printer("2").start();
}
}
/**
* A printer prints its name 1000 times.
*
* @author Franck van Breugel
*/
public class Printer implements Runnable
{
public void run()
{
final int NUMBER = 1000;
for (int i = 0; i < NUMBER; i++)
{
System.out.print(Thread.currentThread().getName());
}
}
}
public class PrinterTest
{
public static void main(String[] args)
{
Printer printer = new Printer();
new Thread(printer, "1").start();
new Thread(printer, "2").start();
}
}