Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Daemon and Non Daemon Thread  RSS feed

 
Radhika Gokhale
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

This is really urgent. I am looking for some info on Daemon and Non Daemon Threads.

Any links for details would be really helpful....


TIA

Radhika
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There isn't much to know. The difference is just the setting of a flag. By definition, the JVM will exit automatically if the only threads still running are daemon threads. Most of the threads the JVM starts automatically are daemon threads; the AWT/Swing event thread is an exception. User threads are non-daemon threads by default. The thread that calls main() is a non-daemon thread as well.

That's about it.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By definition, the JVM will exit automatically if the only threads still running are daemon threads.


I read this too.
On linux, you may make a thread a daemon by suffixing it with a ' &'.
i.e.:
I was unsure, whether this would stop every created thread, because MyServer created only background-Threads.
But a java-Daemon is as I have seen, different from an OS-Daemon.
All Threads in background kept running nicely.
 
Anton Golovin
Ranch Hand
Posts: 531
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Radhika Gokhale:
Hi,

This is really urgent. I am looking for some info on Daemon and Non Daemon Threads.

Any links for details would be really helpful....


TIA

Radhika


You might want to check into how different operating systems treat non-daemon and daemon threads differently priority wise.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both Anton and Stefan seem to be confusing foreground and background processes with daemon and non-daemon threads. Other than analogies one might draw, there's no relationship whatsoever between these two pairs of concepts. Furthermore, the latter pair is a Java concept only -- the OS is completely unaware of the "daemon" flag of a thread, and it has no effect whatsoever on thread scheduling. Contrariwise, running a process in the background on Linux has no effect on the scheduling of the threads within the application.
 
Anton Golovin
Ranch Hand
Posts: 531
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I learn something new every day.

Respectfully,
[ July 19, 2004: Message edited by: Anton Golovin ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!