package edu.nyu.cs9053.concurrency.threads;

/**
 * User: blangel
 * Date: 11/9/14
 * Time: 4:33 PM
 */
public class InterruptingThread {

    public static void main(String[] args) throws Exception {
        Runnable code = new Runnable() {
            @Override public void run() {
                while (!Thread.currentThread().isInterrupted()) {
                    System.out.printf("Howdy from \"%s\"!%n", Thread.currentThread().getName());
                }
            }
        };
        Thread separate = new Thread(code);
        separate.start();

        Thread.sleep(1000L);
        separate.interrupt();

        separate.join();
        System.out.printf("Separate thread completed [ %s ]%n", Thread.currentThread().getName());
    }

}
