• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Program is not getting terminated

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Below is my code which is working fine but it's not getting terminate.

 
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Marshal
Posts: 8884
638
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, It was due to Frame. It worked after disposing of.  Thanks for your help
 
reply
    Bookmark Topic Watch Topic
  • New Topic