wood burning stoves*
The moose likes Threads and Synchronization and the fly likes File lock using Threads in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply locked New topic

File lock using Threads in java

Pandian Ranganathan

Joined: Oct 20, 2009
Posts: 13

i am developing file lock concept in java. i am using two threads. first thread is in running state...second thread will wait untill first thread release... i cant make second thread will wait.. i am getting some exception...

i am getting exception like this

Inside Run...
fileC:\CMPS\Migration\Test\Response File.txt
Channel sun.nio.ch.FileChannelImpl@addbf1
inside second try.....
inside second try----->sun.nio.ch.FileLockImpl[0:9223372036854775807 exclusive valid]
Inside finally.....
Inside Run...
fileC:\CMPS\Migration\Test\Response File.txt
Channel sun.nio.ch.FileChannelImpl@190d11
inside second try.....
Exception java.nio.channels.OverlappingFileLockException
Inside finally.....
at sun.nio.ch.FileChannelImpl$SharedFileLockTable.checkList(Unknown Source)
at sun.nio.ch.FileChannelImpl$SharedFileLockTable.add(Unknown Source)
at sun.nio.ch.FileChannelImpl.tryLock(Unknown Source)
at java.nio.channels.FileChannel.tryLock(Unknown Source)
at FileTest.run(FileTest.java:26)
at FileTest.main(FileTest.java:53)

Thanks in Advance...
Henry Wong

Joined: Sep 28, 2004
Posts: 18507

duplicate topic

Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: File lock using Threads in java
Similar Threads
Problem in File lock using Threads in java
how to set dependencies for jasperreports in my sample program
how to write into a property file from web browser
How to read a file from remote System
RMI - access denied