forked from ReactiveDesignPatterns/CodeSamples
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathUnsafe.java
More file actions
36 lines (28 loc) · 714 Bytes
/
Unsafe.java
File metadata and controls
36 lines (28 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
* Copyright (c) 2018 https://www.reactivedesignpatterns.com/
*
* Copyright (c) 2018 https://rdp.reactiveplatform.xyz/
*
*/
package chapter03;
// Listing 3.1 Unsafe, mutable message class, which may hide unexpected behavior
// #snip
import java.util.Date;
public class Unsafe {
private Date timestamp;
private final StringBuffer message;
public Unsafe(Date timestamp, StringBuffer message) {
this.timestamp = timestamp;
this.message = message;
}
public synchronized Date getTimestamp() {
return timestamp;
}
public synchronized void setTimestamp(Date timestamp) {
this.timestamp = timestamp;
}
public StringBuffer getMessage() {
return message;
}
}
// #snip