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

Database Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

More Books

Students also viewed these Databases questions