SOAP::RPC::StandaloneServer failed in the thread

I wrote a simple soap server as below

NS = ‘http://Test.com/Test’;
class Server < SOAP::RPC::StandaloneServer
def on_init
t = TestClass.new
add_method(t, ‘echo’)
end
end
svr = Server.new(‘TEST’,NS,‘0.0.0.0’,12321)
trap(‘INT’) {svr.shutdown}
svr.start

it can run without problem. However if I run the same piece of code in
a thread, it will not work

Thread.new do

#same code here

end
#wait for the thread

I think the server does not start because the listening port I
specified is not occupied by any application. Does anyone know what
the problem is?