@@ -109,6 +109,7 @@ public synchronized int appraiseSit(int concentrationSiteOccupancy) {
109109 public synchronized void takeARest () {
110110 MasterThief masterThief = (MasterThief ) Thread .currentThread ();
111111 masterThief .setThiefState (MasterThiefStates .WAITING_ARRIVAL );
112+
112113 // sleep until an ordinary thief reaches the collection site and hands a canvas
113114 while (canvasToCollect () == 0 ) {
114115 try { wait (); } catch (InterruptedException e ) {e .printStackTrace ();}
@@ -125,7 +126,7 @@ public synchronized void handACanvas() {
125126 }
126127 inside [ordinaryThief .getThiefID ()] = true ;
127128 registeredThieves [ordinaryThief .getThiefID ()] = true ;
128- partiesInSite [ordinaryThief .getParty (). getID ()] = true ;
129+ partiesInSite [ordinaryThief .getPartyID ()] = true ;
129130 //logger(ordinaryThief, "Entered collection site. Collection Site Occupancy: " + occupancy() + "/" + N_THIEVES_ORDINARY);
130131
131132 // register canvas
@@ -134,7 +135,7 @@ public synchronized void handACanvas() {
134135 if (roomState [ordinaryThief .getRoomID ()] != EMPTY_ROOM )
135136 roomState [ordinaryThief .getRoomID ()] = ordinaryThief .hasCanvas () ? FREE_ROOM : EMPTY_ROOM ;
136137
137- int [] thievesOfParty = ordinaryThief .getParty (). getThieves ();
138+ int [] thievesOfParty = ordinaryThief .getThievesFromParty ();
138139 int nThievesFromParty = 0 ;
139140 for (int thiefFromParty : thievesOfParty ) {
140141 if (registeredThieves [thiefFromParty ])
@@ -144,7 +145,7 @@ public synchronized void handACanvas() {
144145 if (nThievesFromParty == N_THIEVES_PER_PARTY ) {
145146 //logger(ordinaryThief, "Last thief from party leaving Collection Site.");
146147 // clear registered thieves from his party
147- partiesInSite [ordinaryThief .getParty (). getID ()] = false ;
148+ partiesInSite [ordinaryThief .getPartyID ()] = false ;
148149 for (int thiefFromParty : thievesOfParty )
149150 registeredThieves [thiefFromParty ] = false ;
150151 printRoomState ();
@@ -193,16 +194,16 @@ public synchronized void collectACanvas() {
193194 appraisedThief = nextThiefID ;
194195
195196 logger (masterThief , "Waking up Ordinary " + nextThiefID + " to leave the collection site." );
196- notifyAll ();
197197
198- if (thiefQueue .size () == 0 )
199- appraisedThief = -1 ;
198+ notifyAll ();
200199
201200 if (closingParty ) {
202201 closingParty = false ;
203202 masterThief .setActiveAssaultParties (masterThief .getActiveAssaultParties () - 1 );
204203 }
205204
205+ if (thiefQueue .size () == 0 )
206+ appraisedThief = -1 ;
206207
207208 masterThief .setThiefState (MasterThiefStates .DECIDING_WHAT_TO_DO );
208209 }
0 commit comments