# We have a soccer stadium with three entrance doors and need to keep track of the number of spectators currently

This problem has been solved!

Do you need an answer to a question different from the above? Ask your question!

## Question:

public void inc() { final int local = count; count = local + 1; }

a. 0.5 Suppose the stadium is empty, count is zero, and three spectators enter at the same time through different doors. Whatis the conceptually correct value of count once the three spectators are inside?

b. 0.5 Under the same scenario, and given our implementation of inc, what are the possible resulting values for count (assumingmultiple threads of execution)? Which one(s) are conceptually correct? Be careful of the possible resulting values!

Still under the same scenario, one possible ordering of the four steps corresponding to the two invocations of inc is

local1 = count; // f1

count = local1 + 1; // s1 local2 = count; // f2 count = local2 + 1; // s2 local3 = count; // f3 count = local3 + 1; // s3

where local1, local2, and local3 are distinct local variables associated with the three doors.

c. 0.5 (TRUE or FALSE) Is the following ordering possible? f1 s1 s2 f2 f3 s3

d. 1.5 List all possible orderings of these steps, using abbreviations f i for fetch i and s i for set i as shown in the comments.(I.e., you would list the ordering from part b as "f1 s1 f2 s2 f3 s3".)

**Related Book For**

## Fundamentals of Physics

ISBN: 978-0471758013

8th Extended edition

Authors: Jearl Walker, Halliday Resnick

**View Solution**

Create a free account to access the answer

**Cannot find your solution?**

Post a FREE question now and get an answer within minutes.
* Average response time.

**Question Details**

Chapter #

**17**Section: Problems

Problem: 3