you shouldn't use threads in your server-side apps, because the server cannot control those threads, and thus it cannot care for cleaning them up when the application is e.g. undeployed.
What is your use case? Could it be achieved through SessionBeans, MessageDrivenBeans, WebServices or Servlets?
The reason, why I am doing this is because I need to start a Socket Server.
What for do you need the socket server? What does this socket server do that cannot be handled by JBoss services?
If JBoss cannot handle your request: I think you should encapsulate it in a MBean service, which can be started/stopped by the server. The MBean should keep track of all threads and stop them, when it is stopped.
I found this wiki doc about port bindings, hopefully it is helpful: http://www.jboss.org/community/docs/DOC-9038
Another interesting class seems to be this one:
http://docs.huihoo.com/javadoc/jboss/4.0.2/org/jboss/remoting/transport/socket/SocketServerInvoker.java.html (I think it is a MBean, which handles socket requests and calls some custom thread/invoker. But I don't know whether you can plug in your own code in it, it is just a result of doing some google.
Hope this helps
Thanks for your help.
I'm not familiar with JBoss Services yet. It's a shame to say, but we will create the thread ourselves. As always we have no time to make it the right way :-(
But it's good to know how to make it next time right ;-)