1 23 package org.hammurapi.inspectors.testcases.violations; 24 25 30 public class NotifyRuleViolationTestCase { 31 32 private static org.apache.log4j.Logger logger = 33 org.apache.log4j.Logger.getRootLogger(); 34 35 private boolean available = false; 36 private int contents = 0; 37 38 39 public synchronized int get() { 40 while (available) { 41 try { 42 wait(); 44 } catch (InterruptedException e) { 45 logger.warn(e); 46 } 47 } 48 available = false; 49 51 notify(); 53 54 return contents; 55 } 56 57 58 public synchronized void put(final int value) { 59 while (available) { 60 try { 61 wait(); 63 } catch (InterruptedException e) { 64 logger.warn(e); 65 } 66 } 67 contents = value; 68 available = true; 69 71 notify(); 73 } 74 } 75 76 | Popular Tags |