// CSE 332 Section Weeek 10 // Synchronized and Concurrency issues class Bag { String s; Bag() { } synchronized void put(String t) { this.s = t; } synchronized String get() { return s; } void changeContents() { this.s = "whatever"; } } // meanwhile.... in some other class.... Bag b1 = new Bag(); Bag b2 = new Bag(); b2.put("silver"); b1.put("gold"); if(b2.get().equals("silver")) { b2.put(b1.get()); } // what concurrency issues can occur, and what can we do to fix it?