Examlex

Solved

Assume Two Threads Share a BankAccount Object with Balance of Zero

question 13

Multiple Choice

Assume two threads share a BankAccount object with balance of zero (0) , and that the BankAccount class provides deposit and withdraw methods as shown below.Thread one deposits $10 ten times and, concurrently, thread two withdraws $10 ten times.Suppose a race condition occurs, and the race is finished first by thread one.What would you expect balance to be after all thread calls? Assume two threads share a BankAccount object with balance of zero (0) , and that the BankAccount class provides deposit and withdraw methods as shown below.Thread one deposits $10 ten times and, concurrently, thread two withdraws $10 ten times.Suppose a race condition occurs, and the race is finished first by thread one.What would you expect balance to be after all thread calls?    A) $10 B) $20 C) $0 D) a negative amount


Definitions:

Elaboration

The process of adding more detail, explanation, or information.

Short-term Memory

A cognitive system with a limited capacity that is capable of temporarily holding information available for processing.

Memory-span Task

A memory-span task is a cognitive test used to measure the number of items, typically words or numbers, that an individual can hold and recall in short-term memory.

Organization

An entity comprising multiple people, such as a company or society, structured to achieve a particular aim or set of goals.

Related Questions