How to lock a file?

How to lock a file from julia? This came up here.