-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStampedTest.java
More file actions
33 lines (33 loc) · 801 Bytes
/
Copy pathStampedTest.java
File metadata and controls
33 lines (33 loc) · 801 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
//package com.algorithm.demo.thread;
//
//import javax.xml.crypto.Data;
//import java.io.IOException;
//import java.util.concurrent.locks.StampedLock;
//
//
//public class StampedTest {
// private final StampedLock sl = new StampedLock();
//
// void mutate() throws IOException {
// long stamp = sl.writeLock();
// try {
// write();
// } finally {
// sl.unlockWrite(stamp);
// }
// }
//
// Data access() {
// long stamp = sl.tryOptimisticRead();
// Data data = read();
// if (!sl.validate(stamp)) {
// stamp = sl.readLock();
// try {
// data = read();
// } finally {
// sl.unlockRead(stamp);
// }
// }
// return data;
// }
//}