Eclipse Compiler

This commit is contained in:
Izzel_Aliz
2018-05-13 22:42:02 +08:00
parent 23643d7333
commit 4a60cb75de
12 changed files with 44 additions and 415 deletions

View File

@@ -25,17 +25,21 @@ public class TConfigWatcher {
private final Map<WatchService, Triple<File, Object, Consumer<Object>>> map = new HashMap<>();
public TConfigWatcher() {
service.scheduleAtFixedRate(() -> map.forEach((service, triple) -> {
WatchKey key;
while ((key = service.poll()) != null) {
for (WatchEvent<?> watchEvent : key.pollEvents()) {
if (triple.getLeft().getName().equals(Objects.toString(watchEvent.context()))) {
triple.getRight().accept(triple.getMiddle());
service.scheduleAtFixedRate(() -> {
synchronized (map) {
map.forEach((service, triple) -> {
WatchKey key;
while ((key = service.poll()) != null) {
for (WatchEvent<?> watchEvent : key.pollEvents()) {
if (triple.getLeft().getName().equals(Objects.toString(watchEvent.context()))) {
triple.getRight().accept(triple.getMiddle());
}
}
key.reset();
}
}
key.reset();
});
}
}), 1000, 100, TimeUnit.MILLISECONDS);
}, 1000, 100, TimeUnit.MILLISECONDS);
}
public void addOnListen(File file, Object obj, Consumer<Object> consumer) {