class HardwareData { private boolean value = false; HardwareData (boolean value) { this.value = value; } boolean get() { return value; } void set (boolean newValue) { value = newValue; } // must be atomic boolean getAndSet (boolean newValue) { boolean oldValue = this.get(); this.set (newValue); return oldValue; } // must be atomic void swap (HardwareData other) { boolean temp = this.get(); this.set (other.get()); other.set(temp); } }