This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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: 4739
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?
 
Sheriff
Posts: 8269
592
Mac OS X VI Editor BSD Linux
  • 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: 4739
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: 7113
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
 
Don't MAKE me come back there with this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic