| 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
|
|
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)
|
 |
 |
|
|
subject: Object.notify() Wrong Context
|
|
|