aspose file tools
The moose likes Threads and Synchronization and the fly likes Object.notify() Wrong Context Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "Object.notify() Wrong Context" Watch "Object.notify() Wrong Context" New topic
Author

Object.notify() Wrong Context

Isaac Hewitt
Ranch Hand

Joined: Jul 24, 2006
Posts: 179

My method gets the file path in the JTree and feeds it to my outgoing email program MailDialog. The email program cannot send the file because it is locked while open in the JTree. With my method below, it is able to be sent, but the line ob.notify(); gives me a hint in NetBeans "invoking Object outside a synchronized context". This method resides in the subclass of JTree so the line synchronized(this) means this tree. Does anyone know what needs to be done to straighten this out? Thanks.



Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16815
    
  19


The notify() method requires that the lock of the object be held. In your example, you are locking one object, and using a different object to notify.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Object.notify() Wrong Context
 
Similar Threads
JTree and Filesystem?
selecting a JTree node programmatically
XML to DOM to JTree
JTree refresh, with new TreeModel
JTree update