Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Concurrent and Parallel Programming Given the following java class called Parcel_Delivery, class Parcel_Delivery { private int[] b; public Parcel_Delivery(int n) { b = new int[n];

Concurrent and Parallel Programming

Given the following java class called Parcel_Delivery,

class Parcel_Delivery {

private int[] b;

public Parcel_Delivery(int n) {

b = new int[n];

for (int i = 0; i < n; i++) {

b[i] = 0;

}

}

public void deliver(int i, int parcels) {

b[i] = b[i] + parcels;

}

public int empty(int i) {

int result = b[i];

box = 0;

return result;

}

}

  1. Make a thread safe version of class Parcel_Delivery in such a way that delivery deliver parcels at same time and do not block each other.

  1. Add a transfer function, which transfer parcels from one box to another that is thread safe.

  1. Give a lock-free thread safe version of Parcel_Delivery.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions

Question

Describe the three types of start-up firms.

Answered: 1 week ago