Review concepts related to threads

Assignment Help JAVA Programming
Reference no: EM131561836

Assignment: Hard Working Threads

Purpose

To review concepts related to threads

Directions

You will need to download the file Lab Starting Code.zip from Pilot for this lab. This code involves one taskmaster thread and several worker threads. The taskmaster thread creates new tasks and adds them to the order queue. Each task takes a certain number of milliseconds to complete. The worker threads pick up tasks from the order queue and simulate working on them by sleeping for the specified number of milliseconds. The program continues until a total of 100 tasks have been created.

Your tasks for this lab are:

• Right now the queue can behave inconsistently. For example, occasionally two workers can both accept the same task (see below). Modify the program so that this cannot occur.

Worker 3 accepted Task 1: 1007 ms
Worker 1 accepted Task 2: 896 ms
Worker 2 accepted Task 1: 1007 ms

• Right now the program can say it is finished before all of the tasks have been made and completed (see below). Modify the program so that this cannot occur.

Worker 1 accepted Task 1: 1175 ms Finished?
Worker 1 finished Task 1: 1175 ms

• Right now if a worker requests a task to work on but the queue is empty, the acceptTask method will loop until the queue is no longer empty, as shown below. This is called a "busy loop" and it is not an efficient use of CPU time.

Modify this code so that the method instead waits until it has been notified that a new task has been created.

public Task acceptTask() {
while (orders.isEmpty()) {
// looping until there is a task in the queue
}
return orders.poll();
}
• Change the program so that if there are five tasks in the queue, the program will wait until the number of tasks falls below five before adding any more tasks to the queue.

Attachment:- Lab Starting Code.zip

Reference no: EM131561836

Questions Cloud

Describe shortly the disorder and list the main symptoms : Describe shortly the disorder and list the main symptoms. What is thought to be the possible cause of the disorder
What fraction of the large conduit is occupied : The cross section of a large circular conduit has seven smaller equal circular conduits within it. The conduits are tangent to each other as shown in Fig.
What your thoughts regarding the process of enculturation : What are your thoughts regarding the process of enculturation for US children today compared to the enculturation process of children some 40 years ago
What are privacy laws related to information technology use : What are the privacy laws related to Information Technology use and how do they impact you personally? The Apple vs. FBI controversy over unlocking the iPhone.
Review concepts related to threads : To review concepts related to threads. Modify this code so that the method instead waits until it has been notified that a new task has been created.
What is the relationship between thinking and language : What is the relationship between thinking and language? What is the value of thinking in images
Find the area of the window : Find the area of the window outlined by semicircular regions as shown in Fig.
Explain what is the core of ethics according to j rachels : According to the following moral issues- Explain what is the core of ethics according to J. Rachels
How can physical changes during the teenage years : How can physical changes during the teenage years affect self-esteem and identity in an adolescent

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd