In NIO, what is the difference between a mandatory lock and an advisory lock?

A lock makes it possible to lock an entire file or a region of a file. Some filesystems implement advisory locking, which means that programs must all work together in order to preserve file integrity. It’s similar to having a synchronized block, which doesn’t really prevent your data from being corrupted, but just prevents threads to acquire the same lock.
If mandatory locking is implemented in a filesystem, a process cannot access a file or a region on a file in a way that would violate the lock.