Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to wait on EDT without blocking?

843807Sep 10 2010 — edited Sep 13 2010
I have a method a point of entry to which I can't manage, but it's always invoked on EDT.
public Object doLengthyOperation() throws Exception {
    // do some stuff

    return operationResult;
}
I would like to process the operation in a separate thread but I don't want to block the EDT. So the easy way is to show a modal dialog and to hide it when the operation processed. But the operation may last a small amount of time and in that case I want to avoid the dialog. I need something that acts like a modal dialog without a real dialog. When the method returns I should stay on EDT, so I can't simply push a new EventQueue and pop it when the operation done.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 11 2010
Added on Sep 10 2010
29 comments
3,206 views