Web hosting provider - 1424 Elevator Model (on CD) Appendix H 166
1424 Elevator Model (on CD) Appendix H 166 // stop Elevator thread; method run terminates 167 public void stopElevator() 168 { 169 elevatorRunning = false; 170 } 171 172 // Elevator thread’s run method 173 public void run() 174 { 175 while ( isElevatorRunning() ) { 176 177 // remain idle until awoken 178 while ( !isMoving() ) 179 pauseThread( 10 ); 180 181 // close elevatorDoor 182 getDoor().closeDoor( currentFloorLocation ); 183 184 // closing Door takes one second 185 pauseThread( ONE_SECOND ); 186 187 // issue elevatorDeparted Event 188 sendDepartureEvent( currentFloorLocation ); 189 190 // Elevator needs 5 seconds to travel 191 pauseThread( TRAVEL_TIME ); 192 193 // stop Elevator 194 setMoving( false ); 195 196 // swap Floor Locations 197 changeFloors(); 198 199 // issue elevatorArrived Event 200 sendArrivalEvent( currentFloorLocation ); 201 202 } // end while loop 203 204 } // end method run 205 206 // invoked when Person rides Elevator between Floors 207 public synchronized void ride() 208 { 209 try { 210 Thread.sleep( MAX_TRAVEL_TIME ); 211 } 212 catch ( InterruptedException exception ) { 213 // method doorOpened in Person interrupts method sleep; 214 // Person has finished riding Elevator 215 } 216 } 217 Fig. H.12 Class Elevatorrepresents the Elevatortraveling between two Floors, operating asynchronously with other objects (part 5 of 9).
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.