Code example for FileLock

Methods: isValid, release

0
            if (fileChannel.isOpen()) {
                fileChannel.lock("attchement statu :",new CompletionHandler<FileLock, String>() {
                    @Override 
                    public void completed(FileLock result, String attachment) {
                        System.out.println("complete lock file ....");
                        System.out.println(attachment +result.isValid());
                        if (result.isValid()) {
                            try { 
                                result.release();
                            } catch (IOException e) {
                                e.printStackTrace();
                            } 
                            current.interrupt();
                        } 
                    } 
 
                    @Override 
                    public void failed(Throwable exc, String attachment) {
                        System.out.println("error:"+attachment);
                        System.out.println(exc);
                        current.interrupt();