Open synchronization block 1 check if wheel has ticks

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: our current thread to obtain a lock on the object, blocking all other threads from accessing the object until our thread has done its job. Once it has done its job, it releases the lock for other threads to use synchronized(this) { // statements } run() Within forever loop: 0. open synchronization block 1. check if wheel has ticks left 2. if so, set wheelIndex to the next index - use mod operator to wrap back to beginning of array 3. set VisibleImage to new image at new index using setImage() 4. decrement # of ticks 5. close synchronization block run() cont. Outside of synchronization block: 6. Pause animation of slot wheel using parameter passed into constructor Half images vs Full Images •  Avoid landing on half images! •  getWheelIndex() should take in a •  •  double value between 0-1, and return an int (RandomDoubleGenerator()) Wheel index should be an int Don’t forget synchronized(this) Files Required Source Files Image Files Misc * Slots.html bear.jpg * bear-triton.jpg * library.jpg * library-sungod.jpg * sungod.jpg * sungod-bear.jpg * triton.jpg * triton-library.jpg * objectdraw.jar * README * Files given to you Reminders and Tips •  No tutor hours on Monday - plan accordingly START EARLY!! Questions?...
View Full Document

This note was uploaded on 03/13/2014 for the course CSE 11 taught by Professor Staff during the Spring '08 term at UCSD.

Ask a homework question - tutors are online