Write a java program that creates three threads

Assignment Help JAVA Programming
Reference no: EM13702993

Question: The reader-writer problem can be stated as given: 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.

Program: 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 explain the shared memory concept through java program?

 

Reference no: EM13702993

Questions Cloud

Find the minimum number of multiplexer and gates : find the minimum number of multiplexer and gates to realize the given function.
Find the nth largest of 2 sorted arrays of length n : In java, use divide and conquer to find the nth largest of 2 sorted arrays of length n.
When should wildcard characters used in queries : When should wildcard characters used in queries and list the six types of wildcard characters that can be used in Access queries?
When to use and function to set multiple conditions : When to use AND function to set multiple conditions that must be met and how to use AND function to set multiple conditions that must be met?
Write a java program that creates three threads : The reader-writer problem can be stated as given: 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.
Repare a c++ class derived that inherits from base class : Write a C++ class Base has two member functions: //add constructor(s) if needed int f () {return x*25;} //x is a protected data member of Base class virtual int g() {return x *35; }
Write a client code that creates two objects : Write a Java program that (1) Defines a base/super class A, a subclass B (inherits from A), and a subclass C (inherits from B).
What is a java archive : What type of output does the javadoc command generate and how do you view the output and what is a Java archive?
What should a comment at the class level contain : How do you identify a comment so the Javadoc tool will recognize it and what should a comment at the class level contain?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Determine the unit product cost of one pound

Determine the unit product cost of one pound of the Kenya Dark coffee and one pound of the Viet Select coffee and determine the unit product cost of one pound of the Kenya Dark coffee and one pound of the Viet Select coffee.

  Write a program that reads a set of floating-point

Write a program that reads a set of floating-point data values from the input.

  Rewrite this code in order to ask the user for input

rewrite this code in order to ask the user for input and then coverth it from infex to postfix ,, so i want to put a Scanner and this ask the user for input .. how to do it ?

  Trade-offs between quantity and quality of production

Are there inevitable trade-offs between quantity and quality of production and in what ways can job analysis and job redesign help manage there trade-offs?

  What purpose does the wbs serve

What purpose does the WBS serve? Describe the structure of a WBS. How does a WBS contribute to accurate estimates?

  Program that allows the user to enter the last names

Write a program that allows the user to enter the last names of 5 candidates in a college election and the votes received by each candidate. The program should then output each candidates name, the votes reveived by that candidate

  1design an abstract data type in java that represents a

1.design an abstract data type in java that represents a musical pitch noteadt.java. the adt should store the note or

  Calculate the optimal position of the large pipeline

Your task is to calculate the optimal position (on the y-axis) of the large pipeline, so that the total length of all smaller pipelines is shortest

  Development of a graphical user interface

To understand actual communication with an SMTP server can be achieved using TCP Sockets and understand the development of a graphical user interface (GUI) and use of event handling.

  Part-11 exceptions and exception handlinggt create a java

part-11 exceptions and exception handlinggt create a java class called samearraysexception that extends the exception

  Writing a java program that provides simple statistics

You will be writing a Java program that provides simple statistics about the input data. The method stubs are given below. This assignment will give you experience with methods

  Consumer and business product and discuss

Name a product that could be described as both a consumer and business product and discuss why. Describe its attributes, uses and product perceptions of the customers in both markets.

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