module examples.lock; behavior File { WriteLine wl = null; void writeWord(String word){ standardOutput<-print(word) @ currentContinuation; } boolean canIUse(WriteLine wl){ if (this.wl == null){ this.wl = wl; return true; } else return false; } // the following code would always allow the resource to be used, // i.e., not enforcing mutual exclusion // boolean canIUse(WriteLine wl){ // return true; // } void release() { this.wl = null; } void act (String args[]){ WriteLine wl1 = new WriteLine(self, 1, args); WriteLine wl2 = new WriteLine(self, 2, args); wl1<-go(); wl2<-go(); } }