• Post Reply Bookmark Topic Watch Topic
  • New Topic

Create an application that runs in background

 
Akshit dhar
Greenhorn
Posts: 18
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I want to create an app that need should work in as a background process.
It should work until that process is terminated.
How is that possible?
I guess it is related to threads.
Enlighten me please.
 
Stephan van Hulst
Bartender
Posts: 6583
84
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just make one of your non-daemon threads run indefinitely, and start it using javaw.

If you want it to integrate with the OS' background service capabilities, it might be necessary to write an OS specific wrapper that forwards shutdown commands to your application.
 
Tim Holloway
Bartender
Posts: 18417
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:Just make one of your non-daemon threads run indefinitely, and start it using javaw.


Because the JVM shuts down when all of its threads have terminated. As long as at least one thread continues to be active, the JVM remains alive.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!