Join Patrick Royal for an in-depth discussion in this video My solution: Creating threads, part of Code Clinic: Java.
- So far in this solution…we've learned how to generate music in Java…and how to access the mouse, both for locations and clicks.…Naively, it might seem…that those are the only pieces of information required.…Surely we could just set up a loop…to play music whenever the mouse is held down…and stop whenever it is released.…If there were a way to run a direct check…on whether the mouse is currently being held down…then that strategy would work perfectly.…We could simply run a check at the beginning of each loop…and if the mouse is pressed continue the loop.…However, it's not that simple…even if such a loop would work…it would be very inefficient…because you would have to…continually keep checking the mouse.…
This is what's known as a spinlock…and it consumes a lot of resources.…Effectively, when the mouse is not held down…we have an Infinite Loop fronting…or still the spinlock strategy won't even work…due to the way mouse events are handled.…What if the mouse were to click during the loop…rather than at the beginning?…
Patrick introduces challenges and provide an overview of his solutions in Java. Challenges include topics such as statistical analysis, searching directories for images, and accessing peripheral devices.
Visit other courses in the series to see how to solve the exact same challenges in languages like C#, C++, PHP, Python, and Ruby.
Skill Level Intermediate
Problem One: Exploring Lake Pend Oreille
Problem Two: Image Analysis
Problem Three: Eight Queens
Problem Four: Accessing Peripherals
Problem Five: Recursion and Directories
Problem Six: Building the Web
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.