!7 import java.nio.channels.*; import java.nio.file.*; p { File path = programFile("lockfile"); FileChannel channel = FileChannel.open(toPath(path), StandardOpenOption.CREATE, StandardOpenOption.WRITE); repeat with sleep 1 { { temp FileLock lock = channel.tryLock(); if (lock == null) print("Couldn't lock."); else { print("Locked!"); sleepSeconds(1); } } } }