Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ThreadMonitor can enter extended wait on monitor without first checking that the evaluation isn't already complete #153

Closed
LG987234122 opened this issue Jul 12, 2024 · 1 comment · Fixed by #155

Comments

@LG987234122
Copy link

Within ThreadMonitor.run, there's code of the form:

synchronized (monitor) {
    long waitTime = getCheckInterval(runtime);

    if (waitTime == 0) {
  	  waitTime = 1;
    }
    monitor.wait(waitTime);
}

The problem here is that if the JS evaluation has completed just prior to entering the synchronized block, the monitor thread won't notice and enter its extended wait. Placing a check for stop within the synchronized block allows the monitor thread to notice the JS evaluation is already complete, avoiding the unecessary wait.

synchronized (monitor) {
          if (stop.get())
          {
		return;
          }

	  long waitTime = getCheckInterval(runtime);
  
	  if (waitTime == 0) {
		  waitTime = 1;
	  }
	  monitor.wait(waitTime);
  }
@mxro
Copy link
Collaborator

mxro commented Jul 27, 2024

Thank you for raising this issue and suggesting the fix!

The changes has been applied and releases with 0.4.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants