!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!"); //appendToFile(path, "test\n"); channel.write(ByteBuffer.wrap(toUtf8("test\n"))); sleepSeconds(1); } } } }