Oracle
1Z0-895 · Question #32
A developer writes a Singleton bean that holds state for a single coordinate: An update thread acquires an EJB reference to CoordinateBean and alternates between invoking SetCoordinate (0, 0) and…
The correct answer is B. [1, 1]. The value could be either [0,0] or [1,1]. Java has several design patterns Singleton Pattern being the most commonly used. Java Singleton patternbelongs to the family of design patterns, that govern the instantiation process. This design pattern proposes that at any time there…
High Availability
Question
A developer writes a Singleton bean that holds state for a single coordinate: An update thread acquires an EJB reference to CoordinateBean and alternates between invoking SetCoordinate (0, 0) and SetCoordinate (1, 1) in a loop. At the same time, ten reader threads each acquire an EJB reference to CoordinateBean and invoke getCoordinate () in a loop. Which represents the set of all possible coordinate values [X, Y] returned to the reader threads?
Exhibit
Options
- A[0, 0]
- B[1, 1]
- C[0, 0], [1, 1]
- D[0, 0], [0, 1], [1, 0], [1, 1]
How the community answered
(39 responses)- A13% (5)
- B79% (31)
- C5% (2)
- D3% (1)
Explanation
The value could be either [0,0] or [1,1]. Java has several design patterns Singleton Pattern being the most commonly used. Java Singleton patternbelongs to the family of design patterns, that govern the instantiation process. This design pattern proposes that at any time there can only be one instance of a singleton (object) created by the JVM.
Topics
#singleton bean#lock contention#read/write concurrency#container locking
Community Discussion
No community discussion yet for this question.
