Creazione di threads stile 2: esempio
public class ProvaThread implements Runnable {
public static void main (String argv[ ]) {
System.out.println ("Thread corrente: " +
Thread.currentThread ( ));
ProvaThread pt = new ProvaThread ( );
Thread t = new Thread(pt);
try { Thread.sleep (2000); }
catch (InterruptedException e) { }
System.out.println ("Fine main"); }
System.out.println ("Thread run" +
Thread.currentThread ( ));
for (int i = 0; i < 5; i++) {
try {Thread.currentThread ( ).sleep (1000); }
catch (InterruptedException e) { } }
System.out.println ("Fine run");} }