hoijui / JavaOSC

OSC content format/"protocol" library for JVM languages
http://www.illposed.com/software/javaosc.html
BSD 3-Clause "New" or "Revised" License
156 stars 43 forks source link

Why is OSCPortIn running as a daemon thread? #23

Closed JeroenNieuwenhuis closed 7 years ago

JeroenNieuwenhuis commented 9 years ago

I'm making an application that listens to OSC messages and excecutes my code when a message is received. I'm calling my code from the listener so I have one thread which makes the JVM exit (because it's a daemon thread).

I fixed it by making it a normal thread, but I think it'd be nice to have the option to run it as a normal thread.

hoijui commented 8 years ago

i do not understand how that could be useful. as i understand it, a daemon thread is one that is only serving other threads, and for which it makes no sense to keep running if no threads using it are alive. the OSC listening thread is always such a thread, as packets do not have to be read and parsed if no thread is going to consume them. if you have only one other thread running, that is consuming the OSC packets, then i can not see why that one should be a daemon thread. can you maybe explain further, or give a mini-code example? sorry for the very late reply!

JeroenNieuwenhuis commented 8 years ago

If the code you're calling from the listener is very small, making another thread to handle the packets only adds overhead. In that case it'd be the only thread.

hoijui commented 8 years ago

ahhh yeah, i guess that makes sense. thanks for the explanation! :-) i guess i will leave daemon as default, but make it possible to set it as non-daemon, for your type of scenarios, as i guess it is rather an exception then the default case.

hoijui commented 7 years ago

This is now possible in thedevelop branch, and will be in the next release. See commit: 24fa8915ddfef84e5beea81d0e7668a3dbf94569