This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes synchronisation error Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "synchronisation error" Watch "synchronisation error" New topic
Author

synchronisation error

arjun rampal
Ranch Hand

Joined: Jul 08, 2005
Posts: 125
Hi I have a file which if exists should print "got it" else it should print "not got it".Gettin boolean value through for this through res.getres().Now follwoing are two files.Issue is when file is there i get the correct message but when file is not there I am not getting any messgae.




[HENRY: Added code tags]
[ October 29, 2006: Message edited by: Henry Wong ]
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16811
    
  19

There is nothing in the example that you've shown that prints either "got it" or "not got it".

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
arjun rampal
Ranch Hand

Joined: Jul 08, 2005
Posts: 125
Hi this is third file to get it
if (res.getres()){
System.out.println("got it")

else{
System.out.println(" not got it")
}
where res.getres returning boolean value
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16811
    
  19

The "not got it" message will never print. The reason is because the getres() method will always return true -- while the avai variable is false it will wait.

Henry
arjun rampal
Ranch Hand

Joined: Jul 08, 2005
Posts: 125
Hi how to rectify this
regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: synchronisation error
 
Similar Threads
please critique the code
Beginner Question on threads
Feed the Pets
Thread Communication using wait() and notify()
notify