Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Regular Contributor
Posts: 77
Registered: ‎02-17-2010
My Device: Not Specified

Run thread after application exit

Hi all,


I need to run app after exiting the application. but once application exits,my thread is shutting down.. plz help to do this..


Actuall requiremnt is while exiting i need to save all images in database.. there might be 50 to 100 images.i have written code to save in database in onClose.. so when user presses back it takes time to save images and then exits the app.. user feels like back press is hanging...


public boolean onClose() {

		System.out.println("**************************** started thread ");
		if (GlobalData.htChannelLogos.size() > 0) {
		System.out.println("**************************** closed thead ");

		return super.onClose();


Help me how can i save images in background..





Posts: 285
Registered: ‎08-26-2011
My Device: 9900
My Carrier: Not Specified

Re: Run thread after application exit

Use this:


public boolean onClose() 
	return true;


Feel free to click THUMB symbol if answer is correct.

Feel free to click LIKE button if the solution helps you;

Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Run thread after application exit

putting the application into the background and running the thread is the correct approach.
just note that a thread executes aynchronally, your code above will call system.exit immediately.
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Posts: 146
Registered: ‎07-24-2008
My Device: none
My Carrier: none

Re: Run thread after application exit

But in that case application will keep running in background. In addition to above you can call the system.exit, once you are done saving the images in the background.
Thanks & Regards,
Ankit Dubey
Module Lead Software Engineer, mLabs
Impetus InfoTech (India) Pvt. Ltd.