0

I am using executor service in my code the number of threads that are used is more than a 100 . Once the execution is complete , shutdown() method is called on the executor service and then awaitTermination() is called.

The java class is invoked by using a shell script from linux terminal . I would like to know what happens when the execution is stopped by pressing ctrl+C in a state where executor service is started but not shutdown completely.

Does it result in the threads being killed ,their memory being cleaned up and resources being deallocated or would it result in memory leaks.

sujith
  • 665
  • 2
  • 9
  • 22
  • Are you asking whether the OS fails to clean up a program's memory based on the state of a Java class? If this was the case, it would be a bug in the OS. – Peter Lawrey Aug 23 '15 at 12:15
  • What I am asking is : "Generally when executor service is used , it is recommended to shutdown the executor service once the jobs are complete to ensure there are no leaking threads. Incase if I force stop the running program , will the clean up take place?(It doesn't matter whether clean up is done by OS or by JVM)" – sujith Aug 23 '15 at 15:32
  • 1
    When the OS cleans up a process, all its resources are reclaimed. Only temporary files might be left behind. – Peter Lawrey Aug 23 '15 at 19:30

0 Answers0