By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,930 Members | 1,492 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,930 IT Pros & Developers. It's quick & easy.

java is different from C

P: n/a
In C you can create a TRUE daemon which you start by executing it
and it severs itself from the terminal you started it from.

In java you can use javaw in windows, but in unix you would have to
do "nohup java programname &" . But this is not really a TRUE daemon
because if you now say "fg" it is back under command line control.

I read many examples and they all say that in java a daemon thread
will exit when there are no non-daemon threads because the JVM believes
that daemon threads are meant to provide support for non-daemon
threads.

Is all this correct ? I am trying to make a simple java socket server that
will run on a unix machine or windows machine. Are there any good
examples available say on a university website ?
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"mthlv12" <mt*****@earthlink.net> wrote in message
news:_d******************@newsread3.news.atl.earth link.net...
In C you can create a TRUE daemon which you start by executing it
and it severs itself from the terminal you started it from.

In java you can use javaw in windows, but in unix you would have to
do "nohup java programname &" . But this is not really a TRUE daemon
because if you now say "fg" it is back under command line control.

I read many examples and they all say that in java a daemon thread
will exit when there are no non-daemon threads because the JVM believes
that daemon threads are meant to provide support for non-daemon
threads.

Is all this correct ? I am trying to make a simple java socket server that will run on a unix machine or windows machine. Are there any good
examples available say on a university website ?


Which executable you use to start a Java program has no bearing on whether a
Thread is a daemon thread or not. This refers to whether the boolean daemon
member of a given Thread object is set to true. Any Java application must
have at least one non-daemon, started, and non-dead Thread at all times or
the application will terminate, along will any daemon Threads in it.
Jul 17 '05 #2

P: n/a
"mthlv12" <mt*****@earthlink.net> wrote in message
news:_d******************@newsread3.news.atl.earth link.net...
In C you can create a TRUE daemon which you start by executing it
and it severs itself from the terminal you started it from.

In java you can use javaw in windows, but in unix you would have to
do "nohup java programname &" . But this is not really a TRUE daemon
because if you now say "fg" it is back under command line control.

I read many examples and they all say that in java a daemon thread
will exit when there are no non-daemon threads because the JVM believes
that daemon threads are meant to provide support for non-daemon
threads.

Is all this correct ? I am trying to make a simple java socket server that will run on a unix machine or windows machine. Are there any good
examples available say on a university website ?


Oh, and in the future, please post to comp.lang.java.help or
comp.lang.java.programmer. This group isn't supposed to exist.
Jul 17 '05 #3

P: n/a
On Mon, 16 Aug 2004 22:06:50 GMT, mthlv12 wrote:
In java you can use javaw in windows, but in unix you would have to
do "nohup java programname &" . But this is not really a TRUE daemon
because if you now say "fg" it is back under command line control.


Try this instead:

( nohup java programname > /dev/null 2>&1 < /dev/null & ) &

Now you can't get it back with fg.

/gordon

--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.