package edu.nyu.cs9053.concurrency.threads;

/**
 * User: blangel
 * Date: 11/9/14
 * Time: 4:19 PM
 */
public class Threads {

    public static void main(String[] args) throws Exception {
        // code to run concurrently
        Runnable code = new Runnable() {
            @Override public void run() {
                // will be run on a new thread!
                System.out.printf("Howdy from \"%s\"!%n", Thread.currentThread().getName());
            }
        };
        // create a thread and give it the code to execute
        Thread separate = new Thread(code);
        // start the thread
        separate.start();
        // at this point the separate thread may be running.
        // either do something else or wait for the thread to finish
        separate.join();
        System.out.printf("Separate thread completed [ %s ]%n", Thread.currentThread().getName());
    }

}
