From the course: Java Threads

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Challenge: Webinar polling system

Challenge: Webinar polling system - Java Tutorial

From the course: Java Threads

Challenge: Webinar polling system

(upbeat music) - [Instructor] Now it's time for our second challenge. To solve this challenge, you can use some of the thread class methods that you've learned in chapter three. In this challenge, I want you to change the VotingRunnable to simulate votes coming in at random intervals. That is, while performing the task within the run method, pause the thread for a random amount of time between zero and thousand milliseconds. You'll need to generate a random number between zero and thousand for this. There are different ways to do that, but I've given a suggestion to you in code comments. You should also change the countingRunnable so that counting of votes happens every two seconds. Also both voting and counting tasks should stop after 30 seconds. A Boolean flag set to a default value of false is available in the two runnable classes. The tasks executed by the run method can continue while this flag is false. The…

Contents