public class ThreadSummary {
public static void main ( String[ ] args) {
new MyThread1 ( ) . start ( ) ;
new Thread ( new MyThread2 ( ) ) . start ( ) ;
ExecutorService ser = Executors. newFixedThreadPool ( 1 ) ;
Future< Integer> result = ser. submit ( new MyThread3 ( ) ) ;
try {
int r = result. get ( ) ;
System. out. println ( r) ;
} catch ( InterruptedException e) {
e. printStackTrace ( ) ;
} catch ( ExecutionException e) {
e. printStackTrace ( ) ;
}
ser. shutdown ( ) ;
}
}
class MyThread1 extends Thread {
@Override
public void run ( ) {
System. out. println ( "MyThread1" ) ;
}
}
class MyThread2 implements Runnable {
public void run ( ) {
System. out. println ( "MyThread2" ) ;
}
}
class MyThread3 implements Callable < Integer> {
public Integer call ( ) throws Exception {
System. out. println ( "MyThread3" ) ;
return 10 ;
}
}