I have created a custom crawler using crawler4j. In my app, I create a lot of controllers and after a while, the number of threads in the system will hit the maximum value and the JVM will throw an Exception. Even though I call ShutDown()
on the controller, and set it as null
and call System.gc()
, the threads in my app remain open and the app will crash.
I used the jvisualvm.exe
(Java VisualVM) and saw that at one point my app hits 931 threads.
Is there a way I can immediately kill all the threads created by the CrawlController
object of the crawler4j project? (or any other object for that matter)