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

  Write a program to print out a simplified bill

Write a program to print out a simplified bill. The customer's name, the number of hours of labor, and the cost of parts and supplies should be entered in response to INPUT statements.

  Conduct an internet search for javadb tutorial you might

please write a 200-400 word response to the following questionq1. conduct an internet search for javadb tutorial. you

  Write a java application that allows the user to read

Write a java application that allows the user to read, validate, store, display, sort and search the account number and balance for N bank customers.

  Create a graphical application stackdemogui

Create a graphical application StackDemoGUI that provides a button for push and pop from a stack, a text field to accept a string as input for push, and a text area to show the contents of the stack after each operation.

  Write specifications for method which advances date by one

Write specifications for the method which advances any given date by one day. Comprise a statement of purpose, pre- and post-conditions, and description of parameters.

  How does a client send a string ti the server using udp

How does a client send a string ti the server using UDP? Show what the client would do to get data from some string, and create a datagram packet destined for a server at "www.google.com", port 12345.

  Write program in java-calculate and display mortgage payment

Write the program in Java (with a graphical user interface) and have it calculate and display the mortgage payment amount from user input of the amount of the mortgage.

  Write an application that uses an array to store

Write an application that uses an Array to store 10 messages of type String - You will store this Array with 10 messages

  Your technical leader has submitted additional requirements

a - your technical leader has submitted additional requirements for your application. you have been asked to enhance

  Create an overloaded constructor that provides values

Create a class named BloodData that includes fields that hold a blood type (the four blood types are O, A, B, and AB) and an Rh factor (the factors are + and -).

  Qr codes are a popular way

QR codes are a popular way to encode data for easy reading by computerized cameras. True QR codes contain error correction, format specifiers, version information, and a size variable layout that makes them harder to decode and process

  Why is the order of the execution of two processes important

Modify the code so that the senderReceiver process sends then receives repeatedly suspending itself for 3 seconds between each iteration.

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