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