[
http://jira.jboss.com/jira/browse/JGRP-571?page=comments#action_12376894 ]
Michael Newcomb commented on JGRP-571:
--------------------------------------
So your main() returns after you started a thread ? Then that thread
is a daemon as well ?
No, my main() created and joined a channel, main() then completed. My class is just a
listener on the group, but immediately exits when main() completes (after creating/joining
a channel) because it is just a simple group listener and doesn't send any messages on
it's own accord.
I don't have an issue with all of our threads being daemons, as a
matter of fact I explicitly changed them to daemons not so long ago.
Going to use your own words against you ;) and point you to
http://jira.jboss.com/jira/browse/JGRP-541 where:
Vladimir Blagojevic [27/Jun/07 04:40 PM]
"In particular, it is dangerous to use daemon threads for tasks that might perform
any sort of I/O. Daemon threads are best saved for 'housekeeping' tasks, such as
background thread that periodically removes expired entries from an in-memory cache"
- Brian Goetz (JCIP, page 165)
Bela Ban [29/Jun/07 07:47 AM]
I agree with Vladimir's assertion. The channel needs to be closed correctly for these
threads to terminate.
It should be trivial to have at least 1 thread which is non-daemon in
your app.
Part of my application are grid nodes where they don't 'do' anything until
asked (through a message) to do some work. My main simply starts up, creates/joins a group
and then just waits for messages.
all threads are daemon
----------------------
Key: JGRP-571
URL:
http://jira.jboss.com/jira/browse/JGRP-571
Project: JGroups
Issue Type: Bug
Affects Versions: 2.5
Reporter: Michael Newcomb
Assigned To: Bela Ban
Fix For: 2.6
Create and join a channel, then LockSupport.park() in main.
Dump out all Threads (ctrl-break) and they are all daemon.
Thread Pool threads get marked daemon because they are created from the IO threads (which
are daemon).
Recommend searching for setDaemon(true) and determining if all uses are correct.
Caused my program (which is event/message driven) to immediately exit.
"Incoming Thread,137.161.130.87:1956" daemon prio=10 tid=0x033ad400 nid=0x2378
waiting on condition [0x040cf000..0x040cfc94]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x24107308> (a
java.util.concurrent.SynchronousQueue$TransferStack)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
at
java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:422)
at
java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:323)
at java.util.concurrent.SynchronousQueue.take(SynchronousQueue.java:857)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:946)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:906)
at java.lang.Thread.run(Thread.java:619)
"MERGE2.FindSubgroups thread (channel=iewtpt, local_addr=137.161.130.87:1956)"
daemon prio=6 tid=0x033a9800 nid=0xe70 waiting on condition [0x0407f000..0x0407fd14]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at org.jgroups.util.Util.sleep(Util.java:851)
at org.jgroups.protocols.MERGE2$FindSubgroups.run(MERGE2.java:265)
at java.lang.Thread.run(Thread.java:619)
"OOB Thread,137.161.130.87:1956" daemon prio=10 tid=0x0337b400 nid=0x24bc
waiting on condition [0x0411f000..0x0411fd94]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x241000f0> (a
java.util.concurrent.SynchronousQueue$TransferStack)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
at
java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:422)
at
java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:323)
at java.util.concurrent.SynchronousQueue.take(SynchronousQueue.java:857)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:946)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:906)
at java.lang.Thread.run(Thread.java:619)
"ServerSocket acceptor thread (channel=iewtpt)" daemon prio=6 tid=0x033a8800
nid=0x1e38 runnable [0x0402f000..0x0402fb14]
java.lang.Thread.State: RUNNABLE
at java.net.PlainSocketImpl.socketAccept(Native Method)
at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)
- locked <0x24100258> (a java.net.SocksSocketImpl)
at java.net.ServerSocket.implAccept(ServerSocket.java:450)
at java.net.ServerSocket.accept(ServerSocket.java:421)
at org.jgroups.protocols.FD_SOCK$ServerSocketHandler.run(FD_SOCK.java:1073)
at java.lang.Thread.run(Thread.java:619)
"UDP mcast receiver,137.161.130.87:1956" daemon prio=10 tid=0x0303ec00
nid=0x2170 runnable [0x03fdf000..0x03fdfc14]
java.lang.Thread.State: RUNNABLE
at java.net.PlainDatagramSocketImpl.receive0(Native Method)
- locked <0x24100418> (a java.net.PlainDatagramSocketImpl)
at java.net.PlainDatagramSocketImpl.receive(PlainDatagramSocketImpl.java:136)
- locked <0x24100418> (a java.net.PlainDatagramSocketImpl)
at java.net.DatagramSocket.receive(DatagramSocket.java:712)
- locked <0x24100458> (a java.net.DatagramPacket)
- locked <0x24100478> (a java.net.MulticastSocket)
at org.jgroups.protocols.UDP.run(UDP.java:247)
at java.lang.Thread.run(Thread.java:619)
"UDP ucast receiver,137.161.130.87:1956" daemon prio=6 tid=0x02ff3000
nid=0x2734 runnable [0x03f8f000..0x03f8fb94]
java.lang.Thread.State: RUNNABLE
at java.net.PlainDatagramSocketImpl.receive0(Native Method)
- locked <0x24100680> (a java.net.PlainDatagramSocketImpl)
at java.net.PlainDatagramSocketImpl.receive(PlainDatagramSocketImpl.java:136)
- locked <0x24100680> (a java.net.PlainDatagramSocketImpl)
at java.net.DatagramSocket.receive(DatagramSocket.java:712)
- locked <0x241006c0> (a java.net.DatagramPacket)
- locked <0x241006e0> (a java.net.DatagramSocket)
at org.jgroups.protocols.UDP$UcastReceiver.run(UDP.java:916)
at java.lang.Thread.run(Thread.java:619)
"main" prio=6 tid=0x001ca000 nid=0x208 waiting on condition
[0x002af000..0x002afe54]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:283)
at HostNode.main(HostNode.java:607)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira