aspose file tools*
The moose likes Threads and Synchronization and the fly likes Confusion in Lock Interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Confusion in Lock Interface" Watch "Confusion in Lock Interface" New topic
Author

Confusion in Lock Interface

vivek dhiman
Ranch Hand

Joined: Aug 05, 2011
Posts: 130

Hi
I have doubt to understand how lock works to maintain synchronization. I had the sample code which i was trying to implement synchronization using Lock. But it doesn't work.

Client Class

I want unique values till 300 in value.txt. Please tell me where i am wrong.
Thanks
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

vivek dhiman wrote:...But it doesn't work.
...
I want unique values till 300 in value.txt. Please tell me where i am wrong.

You need to learn to describe your problems better. ItDoesntWorkIsUseless (<- link). We know what you want, but what happens that you don't expect or what error messages do you get?


You create a new lock every time the method is called. So how do you expect it to synchronize?


Steve
vivek dhiman
Ranch Hand

Joined: Aug 05, 2011
Posts: 130

Thanks Steve. Now txt file have unique values till 300.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Confusion in Lock Interface