|
@@ -13,16 +13,17 @@ public class SafeCopier extends Copier {
|
13
|
13
|
|
14
|
14
|
public SafeCopier(String toCopy) {
|
15
|
15
|
super(toCopy);
|
|
16
|
+ alohomora = new ReentrantReadWriteLock();
|
16
|
17
|
}
|
17
|
18
|
|
18
|
19
|
public void run() {
|
19
|
|
- alohomora = new ReentrantReadWriteLock();
|
20
|
20
|
alohomora.writeLock().lock();
|
21
|
21
|
alohomora.readLock().lock();
|
22
|
22
|
try {
|
23
|
23
|
while (stringIterator.hasNext()) {
|
24
|
24
|
copied += stringIterator.next() + " ";
|
25
|
25
|
}
|
|
26
|
+ copied = copied.trim();
|
26
|
27
|
} finally {
|
27
|
28
|
alohomora.writeLock().unlock();
|
28
|
29
|
alohomora.readLock().unlock();
|