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 - 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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Pausing execution of a thread3m 52s
-
(Locked)
Interrupting a thread5m 42s
-
(Locked)
Implementing thread interruptions6m 13s
-
(Locked)
Making a thread to wait until another thread terminates5m 39s
-
(Locked)
Other useful methods of the Thread class2m 42s
-
(Locked)
Challenge: Webinar polling system1m 53s
-
(Locked)
Solution: Webinar polling system5m 9s
-
(Locked)
-