code: public void lock() throws IOException, InterruptedException {
          if (channel == null) {
              initializeChannel();
          }
          lockSem.acquire();
          lock = channel.lock();
      }
docs: Lock the port file.