/* * 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 * @version 1.0 07/04/08 */ package firststeps; import java.util.Date; public class ThreadsHelloWorldSyncSetGet_Get implements Runnable { private ThreadsHelloWorldSyncSetGet_HoldValue objHoldValue; public ThreadsHelloWorldSyncSetGet_Get(ThreadsHelloWorldSyncSetGet_HoldValue objHoldValue) { this.objHoldValue = objHoldValue; } public void run() { String strMsg; String strThreadName = Thread.currentThread().getName(); System.out.println(strThreadName + " - Start Time - " + (new Date()).toString()); try { while ( ! objHoldValue.isBlnFinished() ) { strMsg = objHoldValue.getSyncValue(); System.out.println(strThreadName + " - Got it! - " + strMsg + " - " + (new Date()).toString()); } } catch (InterruptedException e) { //Time to quit! } System.out.println(strThreadName + " - Stop Time - " + (new Date()).toString()); } }