• Post Reply Bookmark Topic Watch Topic
  • New Topic

need to build daemon

 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello i like to build simple application that will listen to incoming events
i knew i need to program daemon that will always run after starting .
can some one please point me to simple tutorial about daemon threads?
or can some tell me if im looking in the right direction .
Thanks
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you're imagining that there's much more difference between daemon and ordinary threads than there is.

The only difference is that ordinary threads are included in the test that the JVM uses to determine when it shuts down, and daemon threads are not. So, when all ordinary threads have finished, the JVM shuts down; at this time, any daemon threads will be forcibly terminated.

To make a thread daemon, call setDaemon(true) before starting it.

That's all there is to it. Nothing else to learn about daemon threads.
 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i guess i didn't explain my self plus i didn't understand what is daemon thread
what i need is to actually build some of daemon (its doesn't need to be thread )
that waits to event , what is the best way and performance prove method
 
Chris Hurst
Ranch Hand
Posts: 443
3
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
He means a Unix background process equivalent like a Windows service (-ish) . Just to clarify this has nothing to do with daemon threads I suspect as such or really threading at all as I suspect you'll just have a single thread. I suggest either someone move this to a different forum ??? or I suggest the author reposts.

As I have no idea what OS is target'ed I'll make a random (probably inaccurate) statement and suggest your probably after some OS component \ utility \ batch file ?? or bit of C++ code that can be installed as a process / service and can kick off the Java . On Windows its some C++ that installs itself as a service and kicks of the Java usually using JNI . I'm sure they'll be some Unix guru's who'll answer this is in a flash but clearly state your target OS and post in one of the other forums.
 
Joe Ess
Bartender
Posts: 9361
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a number of applications that communicate with publish-subscribe networks or message queues that consist of:

If you want to run such processes as services, you'd need to jump through some hoops (search for "java service" and your OS), but since I'm running them on servers that don't go up and down a lot, I start them manually with nohup.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!