Solved

Is there a way of pausing the execution without using threads?

Posted on 2003-12-09
5
220 Views
Last Modified: 2010-03-31
Hi there,

I have ran into a small problem here. I have a class which has an ActionListener instance with an anonymous class which deals with actionPerformed. I also have a method in the class which returns a value. The thing is I only want to return a value only when an event has occured, for now I'm just using a while loop which does nothing and is controlled by "boolean pauseExecution", and pauseExecution is switched in the event handler. I'm thinking that there must be a better way of doing this, anybody know?

Thanks
0
Comment
Question by:mentar
  • 3
  • 2
5 Comments
 
LVL 92

Expert Comment

by:objects
ID: 9909236
0
 

Author Comment

by:mentar
ID: 9909392
Thank you, however I tried that although it does work it bombards me with  "IllegalMonitorStateException: current thread not owner", the code still seems to run fine though, any ideas what's wrong?
0
 
LVL 92

Accepted Solution

by:
objects earned 125 total points
ID: 9909408
you need to synchronise the block that is calling wait/notify.

eg.

synchronized (o)
{
   o.wait();
}
0
 

Author Comment

by:mentar
ID: 9909436
Thanks a lot, you've really helped me out :)
0
 
LVL 92

Expert Comment

by:objects
ID: 9909469
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Windows 10 IE Certificate Issue 10 51
hibernate example issues from command prompt 10 50
jmss example java 2 24
running on tomcat not jboss eap 7.0 3 19
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question