Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are working as a programmer for developing a game show. The host of the show asked you to develop a Java program that will

You are working as a programmer for developing a game show. The host of the show asked you to develop a Java program that will help the game show running smoothly. The rules for the show is that it will ask the player a couple of questions. If the player can answer the question correctly in 10 seconds, he/she will score one/1 point. If the players answer is wrong or if he/she does not answer the question within 10 seconds, the correct answer is displayed and the player does not score any points. After getting an answer or running out of time, the next question is displayed. From the rules above you can get the sense this program needs to run in parallel manner to handle different tasks at the same time. You can use locks/conditions to ensure thread synchronization. We suggest that you should use three threads to handle three tasks.

Below is a skeleton of logic that you might follow:

printQuestion thread{

// start timer thread

// wait for answer or timeout

// save response from user

// print correct, wrong or timeout

}

reader_thread{

// check for end of program

// read answer;

// move answer to global variable

// release printer thread

}

timer_thread(int num) {

// wait 10 seconds; you can use sleep() here

// still waiting for this question?

// put TIMEOUT value as response

// release printer thread

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 3 Lnai 9286

Authors: Albert Bifet ,Michael May ,Bianca Zadrozny ,Ricard Gavalda ,Dino Pedreschi ,Francesco Bonchi ,Jaime Cardoso ,Myra Spiliopoulou

1st Edition

ISBN: 3319234609, 978-3319234601

More Books

Students also viewed these Databases questions

Question

What disadvantages or opportunity costs can you identify with TDI?

Answered: 1 week ago

Question

3. What is ethnocentric bias?

Answered: 1 week ago