• Post Reply Bookmark Topic Watch Topic
  • New Topic

Program is not getting terminated  RSS feed

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Below is my code which is working fine but it's not getting terminate.

 
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it's not getting terminate. 

Are there any loops that don't end?
Are there any read statements that are blocking waiting for input?

Add some print statements to see where the program's execution is going.

What prints on the console when you execute the program?
 
Sheriff
Posts: 4931
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
somashaker goud wrote:Below is my code which is working fine but it's not getting terminate.

So it isn't working fine, unless we have different definitions about "fine".

Would you like to provide more details, like, what were your inputs? (probably file content).

Or maybe just copy/paste output and highlight where it stuck and what you'd expect to happen further?
 
somashaker goud
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am passing input as a file. It's reading data from file and printing required output. Even finally block is getting executed. Below is the output which I am getting.

Sum of numbers in file is 112
helo

After completion of finally block it's not getting terminated
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After completion of finally block

Did you add a print statement at the end of the program just before the ending } for the main() method?  Did it print anything?

I think some thread is holding JVM from closing
From the API doc for the Thread class:

The Java Virtual Machine continues to execute threads until either of the following occurs:

The exit method of class Runtime has been called and the security manager has permitted the exit operation to take place.
All threads that are not daemon threads have died, either by returning from the call to the run method
or by throwing an exception that propagates beyond the run method.    

The Java Virtual Machine exits when the only threads running are all daemon threads.


Make sure all the GUI objects have been fully released so any threads associated with them end.
 
Sheriff
Posts: 4289
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's definitely the Frame that's hanging on.  Try dispose().

Also, see this:

https://docs.oracle.com/javase/8/docs/api/java/awt/doc-files/AWTThreadIssues.html
 
somashaker goud
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, It was due to Frame. It worked after disposing of.  Thanks for your help
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!