[HtmlUnit] SVN: [13761] trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/ javascript/background/DefaultJavaScriptExecutor.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[HtmlUnit] SVN: [13761] trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/ javascript/background/DefaultJavaScriptExecutor.java

rbri
Revision: 13761
          http://sourceforge.net/p/htmlunit/code/13761
Author:   rbri
Date:     2017-03-15 20:41:15 +0000 (Wed, 15 Mar 2017)
Log Message:
-----------
support js thread interruption

Modified Paths:
--------------
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/background/DefaultJavaScriptExecutor.java

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/background/DefaultJavaScriptExecutor.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/background/DefaultJavaScriptExecutor.java 2017-03-15 20:40:10 UTC (rev 13760)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/background/DefaultJavaScriptExecutor.java 2017-03-15 20:41:15 UTC (rev 13761)
@@ -138,7 +138,7 @@
         // this has to be a multiple of 10ms
         // otherwise the VM has to fight with the OS to get such small periods
         final long sleepInterval = 10;
-        while (!shutdown_ && webClient_.get() != null) {
+        while (!shutdown_ && !Thread.currentThread().isInterrupted() && webClient_.get() != null) {
             final JavaScriptJobManager jobManager = getJobManagerWithEarliestJob();
 
             if (jobManager != null) {
@@ -164,7 +164,7 @@
             }
 
             // check for cancel
-            if (shutdown_ || webClient_.get() == null) {
+            if (shutdown_ || Thread.currentThread().isInterrupted() || webClient_.get() == null) {
                 break;
             }
 
@@ -173,7 +173,7 @@
                 Thread.sleep(sleepInterval);
             }
             catch (final InterruptedException e) {
-                // nothing, probably a shutdown notification
+                Thread.currentThread().interrupt();
             }
         }
     }


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop