Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

File lock using Threads in java

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi,

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
true
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
true
Channel sun.nio.ch.FileChannelImpl@190d11
inside second try.....
Exception java.nio.channels.OverlappingFileLockException
Inside finally.....
java.nio.channels.OverlappingFileLockException
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...
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
duplicate topic
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic