GreetingDriver2 - JOptionPane.showMessageDialog(null,...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
/** A driver to run the thread */ import javax.swing.JOptionPane ; public class GreetingDriver2 { public static void main(String[] args) { Runnable r1 = new GreetingRunnable("Hello") ; Runnable r2 = new GreetingRunnable("Goodbye") ; Thread thread1 = new Thread(r1) ; Thread thread2 = new Thread(r2) ; thread1.start() ; thread2.start() ; JOptionPane.showMessageDialog(null, "Interrupt thread1 when pressed") ; thread1.interrupt() ;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: JOptionPane.showMessageDialog(null, "Interrupt thread2 when pressed") ; System.out.println("thread2 is interrupted: " + thread2.interrupted()) ; thread2.interrupt() ; System.out.println("thread2 is interrupted?: " + thread2.interrupted()) ; System.out.println("thread2 is alive?: " + thread2.isAlive()) ; JOptionPane.showMessageDialog(null, "End program?") ; System.exit(0) ; } }...
View Full Document

Ask a homework question - tutors are online