Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Threads and Synchronization and the fly likes Thread problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Thread problem" Watch "Thread problem" New topic
Author

Thread problem

Supun Lakshan Dissanayake
Ranch Hand

Joined: Oct 26, 2012
Posts: 132

I made a JFrame and add button with ActionListener (I know how to perform an action on ActionEvent )

i used a thread to perform a task by following code snippet



PROBLEM:

But if user closes JFrame accidentally before executing myMethod() task will never performed.
I need to perform complete execution of myMethod() even user closes JFrame accidentally.
How do i do that? I'm an absolute beginner for Threads,Runnable ...

Thanks !!


Are you better than me? Then please show me my mistakes..
Niraj Jha
Ranch Hand

Joined: Feb 20, 2013
Posts: 63

Why do you use a thread to perform the task?
Supun Lakshan Dissanayake
Ranch Hand

Joined: Oct 26, 2012
Posts: 132

Niraj Jha wrote:Why do you use a thread to perform the task?


Because i need to get a print using Jasper Reports.
It is painfully SLOW and unable to do anything till JasperViewer previews print.
So I decided to use thread for jasper Report printing process
madhava Thamata
Greenhorn

Joined: Mar 24, 2013
Posts: 3
Hi,

try dispose method in window close action listeener

Thanks,
Madhava
Supun Lakshan Dissanayake
Ranch Hand

Joined: Oct 26, 2012
Posts: 132

madhava Thamata wrote:Hi,

try dispose method in window close action listeener

Thanks,
Madhava


Oh! I almost forget it.
Thanks for the posts guys!!!
 
GeeCON Prague 2014
 
subject: Thread problem