Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Analyze the following program and indicate what is true class Account { double balance; void withdraw(double amount) { balance -= amount; } void deposit(double amount)

Analyze the following program and indicate what is true

class Account {

double balance;

void withdraw(double amount)

{

balance -= amount;

}

void deposit(double amount)

{

balance += amount;

}

void transfer(Account from, Account to, double amount)

{

sync(from); sync(to);

from.withdraw(amount); to.deposit(amount);

release(to);

release(from); } }

a. should there be two threads which attempt to run transfer(a, b) and transfer(b, a) at the same time, then a deadlock is going to occur because the developer did not indicate the thread priority

b. should there be two threads which attempt to run transfer(a, b) and transfer(b, a) at the same time, then a deadlock is not going to occur because the developer correctly synchronized both from and to inside the method transfer

c. all answers are wrong

d. should there be two threads which attempt to run transfer(a, b) and transfer(b, a) at the same time, then a deadlock is going to occur because they try to acquire the resources in reverse order.

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

More Books

Students also viewed these Databases questions

Question

Explain the purpose of a business plan.

Answered: 1 week ago

Question

Briefly explain the various types of leadership ?

Answered: 1 week ago

Question

Explain the need for and importance of co-ordination?

Answered: 1 week ago

Question

Explain the contribution of Peter F. Drucker to Management .

Answered: 1 week ago

Question

What is meant by organisational theory ?

Answered: 1 week ago

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago