/* * Copyright (c) Michael Thomas, All Rights Reserved. (michael@michael-thomas.com) * * Permission to use, copy, modify, and distribute this software * and its documentation for NON-COMMERCIAL purposes and without * fee is hereby granted provided that this copyright notice * appears in all copies. Exceptions must be in writing between the * copyright holder and entity using the content. * * THE COPYRIGHT HOLDER MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE COPYRIGHT HOLDER SHALL NOT BE LIABLE FOR * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ /** * @author Michael Thomas - michael@michael-thomas.com * @version 1.0 07/04/08 */ package firststeps; import java.util.Date; public class ThreadsHelloWorldSyncSetGet_Run { public static void main(String args[]) throws InterruptedException { String strThreadName = Thread.currentThread().getName(); System.out.println(strThreadName + " - Begin - " + (new Date()).toString()); ThreadsHelloWorldSyncSetGet_HoldValue objHoldValue = new ThreadsHelloWorldSyncSetGet_HoldValue(); ThreadsHelloWorldSyncSetGet_Set objSetRunnable = new ThreadsHelloWorldSyncSetGet_Set(objHoldValue); Thread objSetThread = new Thread(objSetRunnable,"ThreadSet"); ThreadsHelloWorldSyncSetGet_Get objGetRunnable = new ThreadsHelloWorldSyncSetGet_Get(objHoldValue); Thread objGetThread = new Thread(objGetRunnable,"ThreadGet"); objSetThread.start(); objGetThread.start(); objSetThread.join(); objHoldValue.setBlnFinished(true); objGetThread.interrupt(); objGetThread.join(); System.out.println(strThreadName + " - Finished - " + (new Date()).toString()); } }