For example, the following program launches a single BytePrinter
thread:
public class ThreadTest {
public static void main(String[] args) {
System.out.println("Constructing the thread...");
BytePrinter bp = new BytePrinter();
System.out.println("Starting the thread...");
bp.start();
System.out.println("The thread has been started.");
System.out.println("The main() method is finishing.");
return;
}
}
Here's some sample output:
$ java ThreadTest Constructing the thread... Starting the thread... The thread has been started. The main() method is finishing. -128 -127 -126 -125 -124 -123 -122 -121 -120 ...
Of course this continues for a couple hundred more lines.