Can someone please write a piece of code for the following and comment each line (except for really simple ones like int x = 5;) explaining what it does?

Objective: write a program that "spins a number wheel" in the background while waiting for you to type "stop" -- when you type stop it pops out what the pointer is currently pointing to (a number 1-10). I want it to change numbers every second by one unit (1,2,3...10) and then loop back. Even though it is behind the scenes, I DON'T want to just generate a random number with the math class. I want someone with perfect timing to be able to get a 10 :P

If you can do this that would be awesome!!!

Recommended Answers

All 3 Replies

...I don't even have a Java class I teach myself it at home... I don't understand the concept and uses of threading though. If you don't want to help me with that program then fine, but then can you explain in general the practical uses of threading for a code that isn't really giant? Like a small sample code where threading is implemented and how it is implemented.

But that was a program I made up on the fly, not a school assignment... Though I DO wish I got to take java in school :D that would be fun ^.^

From the java documentation book - Concurrency

SUMMARY: Even a single application is often expected to do more than one thing at a time. For example, that streaming audio application must simultaneously read the digital audio off the network, decompress it, manage playback, and update its display. Even the word processor should always be ready to respond to keyboard and mouse events, no matter how busy it is reformatting text or updating the display. Software that can do such things is known as [b]concurrent[/b] software.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.