Write a java program that creates 3 threads

Assignment Help JAVA Programming
Reference no: EM13704502

Question: The reader-writer problem can be stated as follows: A shared memory location can be concurrently read by any number of tasks, but when a task must write to the shared memory location, it must have exclusive access.

Write a Java program that creates 3 threads each of them performing 10 reading/writing to the shared location. Use a random number generator to decide if the request is reading or writing (say, 0 for reading, 1 for writing.) Before each action, print out "thread i now ready to read (or write) the shared location", after the action, print out "thread i now finished read (or write) the shared location". Here i could be 0, 1, or 2.

Can you prepare a program to prepare the threads to read and write to a shared location?

Reference no: EM13704502

Questions Cloud

Implement a singly linear linked list : Prepare a C++ using visual studios program to implement a singly linear Linked List - You need to implement singly link list in C++.
Implement assembly language program to find greatest value : Write an assembly language program that will accept two 1-digit numbers (from 0 to 9) from the keyboard, compare the two numbers, and then print out the number of greatest value.
Evaluate the total average of all the inputs : Once the user enters in the desired amount of inputs, they will then select the second button "Calculate".
Create a short assembly program : You need to create a short assembly program named char_int, stored in file char_int.asm, that prompts the user for a character, and then for an integer.
Write a java program that creates 3 threads : Write a Java program that creates 3 threads each of them performing 10 reading/writing to the shared location. Use a random number generator to decide if the request is reading or writing
What is the corresponding key length in bits : What is the size of the key space which can be constructed by such passwords - What is the corresponding key length in bits?
Procedure just prints out the number 10 and returns : Your program will have three procedures. The main procedure (with the asm_main label), will sign on and them call a menu procedure that displays a two line menu:
Perform an attack against the cipher : Perform an attack against the cipher based on a letter frequency count: How many letters do you have to identify through a frequency count to recover the key? What is the cleartext?
Develop a set of six powerpoint : Develop a set of six PowerPoint or MS Word slides or six paragraphs to present the history, current level of usage, typical applications, future prospects and usability for the selected application.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Temporarily move to the street so that the

Driveway is a "last-in, first-out" stack. Of course, when a car owner retrieves a vehicle that wasn't the last one in, the cars blocking it must temporarily move to the street so that the requested vehicle can leave

  Create a road class

Create a Road class. The class should have functions for setting the width of the road in feet and the length of the road in miles. It should also have functions for obtaining the width of the road the length of the road.

  Implement a class called reversewords

Implement a class called ReverseWords that uses a stack to output a set of elements input by the user in reverse order.

  What are the main differences between java programming

question 1 what are the major differences between java programming language and any other language? list and discuss

  Write program that convert us dollar into canadian dollar

Design a new class named Polygon that extends GeometricObject and implements Comparable. The number of sides in polygons varies, you cannot use a certain number of data fields for sides of a polygon - Write a program that passes an unspecified numb..

  Process of buying a soda from a soda machine

Please write a Java Program those steps through the process of buying a soda from a Soda Machine.  You must interact with the consumer. Each Soda is one dollar.

  Write a statement to create a jframe object

Write a statement to create a JFrame object with a title of "My GUI Application" - Write a Java statement to have the object from the question above manage its display area by dividing it into 3 rows which have 4 columns each.

  1 comparing portions of strings write an application that

1. comparing portions of strings write an application that uses string method region-matches to compare two strings

  Simple java program that implements some basic file

Your code will prompt the user to enter a file name. If this file does not exist the program will produce an error message and exit. Otherwise the program will open the file and read a line from the file, reverse the line, and then print the line to ..

  Generate and manipulate music and images

Arrays are a fundamental and versatile tool for representing data of all shapes and sizes In this assignment, you'll see how arrays can be applied to generate and manipulate music and images.

  Ask the user to enter a positive non-zero integer value.

Write a program which aske the user to Enter a positve non-zero integer value. if the value enterd zero or negative print as error message and end the program; otherwise, use the integer to call a method displayPattern(n) which must display the follo..

  Please write the code in java

Please write the code in java for  Recursion,  Sorting and Searching

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