Chapter 2 Flashcards

1
Q

synchronization

A

It includes the use of volatile variables, explicit locks and atomic variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Encapsulation and data hiding

A

Help you to create thread-safe classes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Thread safe class

A

A class is thread-safe when it continues to behave correctly when accessed from multiple threads regardles of the scheduling or interleaving of the execution of those threads by the runtime environment, and with no additional synchronization or other cordination on the part of the calling code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Fixing broken thread access

A

-Dont share the state variable across threads;
-Make the state variable immutable
-Use synchronization whenever accessing the state variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Note

A

When designing thread-safe classes, good object-oriented techniques — encapsulation, immutability, and clear specification of invariants—are
your best friends.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Thread safe class

A

Thread safe classes encapsulate any needed synchronization so that clients nedd to provide their own.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Stateless object

A

Stateless objects are always thread-safe

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly