Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Program 1

Requirements:

i. You can write an application program which shows process/thread synchronization using:

1. Semaphore
2. Monitor
3. Java Synchronized feautre

ii. Among the above synchronization methods, I hope you would pick one method and apply your application program which requires process/thread synchronization.

iii. In case of Java, please refer to the reference found at the bottom.

iv. Final result should be organized as a document which explains the overview and the structure of your program, real code, execution results (including captured image), and the conclusion including justification of your program, lessons you've learned, comments, etc.

Reference 1: Concurrent/Multithreaded Programming in Java

Java is known as one of the first languages to make multithreading easily available to developers. A thread is assigned code through Thread subclass (start() and run() method) or Runnable interface implementation.

from Java Concurrency/Multithreading by Jakob Jenkov

(1) Critical Section in Java

- Every method declared with the synchronized keyword is a critical section.
- Only one execution thread will access one of the methods of an object declared with the synchronized keyword.
- Only one execution thread will access one of the static method declared with the synchronized keyword, but another thread can access other non-static methods of an object of that class.
- Two threads can access two different synchronized methods if one is static and the other one is not.
- If both methods change the same data, you can have data inconsistency errors.

(2) Bank Synchronization Program

- Description

o Account class : using the synchronized keyword, we guarantee correct access to shared data in
concurrent applications

- tmp, to store the value of the account's balance.

o Bank class : makes 100 calls to the subtractAmount() method that decrements the balance by 100 in
each call.

o Company class : makes 100 calls to the addAmount() method that increments the balance by 1000 in
each call.

o TestBank class

- Remark: Only a thread can access the methods of an object that use the synchronized keyword in their declaration. If a thread (A) is executing a synchronized method and another thread (B) wants to execute other synchronized methods of the same object, it will be blocked until the thread (A) ends.

But if thread (B) has access to different objects of the same class, none of them will be blocked.

from Java 7 Concurrency Cookbook by Javier Fernandez Gonzalez (2012)

(3) Blocking Queues

o Java comes with blocking queue implementations in the java.util.concurrent package.

(4) Thread Pools

o Java comes with built in thread pools in the java.util.concurrent package.

(5) Reference

o Java Concurrency/Multithreading Tutorial by Jakob Jenkov

Program 2

• Requirements:

i. We have learned many kinds of CPU scheduling methods:

1. First-Come, First-Served Scheduling
2. Shortest-Job-First Scheduling
3. Priority Scheduling
4. Round-Robin Scheduling
5. Multilevel Queue Scheduling

ii. Among the above scheduling scheme, I hope you would pick one method and simulate the CPU scheduling procedure.

iii. First, you are supposed to implement CPU scheduler.

iv. Next, you need to populate multiple processes. The processes should be managed by your system from the viewpoint of the Operating Systems. This requires that you maintain the corresponding PCBs. Before the creation of processes, it would be better to design the behavior scenario of each process.

v. The scheduler should show the (concurrent) sequence how the prcesses are selected to run their tasks and release (return) their turn to the other processes.

vi. Most importantly, you have to combine the CPU scheduler with the synchronization mechanism in order to prevent multiple processes from accessing the shared resources including system timer, counter on the queue, etc. The scenario should include a certain situation which show that you included the synchronization scheme on the CPU scheduler.

vii. Final result should be organized as a document which explains the overview and the structure of your program, real code, execution results (including captured image), and the conclusion including justification of your program, lessons you've learned, comments, etc.

Java, Programming

  • Category:- Java
  • Reference No.:- M92022008

Have any Question?


Related Questions in Java

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Question slideshows or carousels are very popular in

Question : Slideshows (or carousels) are very popular in websites. They allow web developers to display news or images on the website in limited space. In this code challenge, you are required to complete the JavaScript ...

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Can someone kindly help me to consider whether java

Can someone kindly help me to consider whether Java provides the facility of operator overloading? If it does, may you kindly describe how overloading operators can be accomplished? If not, may you kindly describe why yo ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Answer the following question whats the difference public

Answer the following Question : What's the difference public inheritance and private inheritance? What can derived classes inherit from base classes? What cannot be inherited from base classes?

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As