Re: the right way to kill a java thread on Windows?



On Fri, 2005-04-29 at 15:08 -0700, john wrote:
> I used NetBeans + JDK 1.5.2 to write a simple program using the SocketServer
> class, on my Windows 2000 pc. The program dies not die when I kill it. I
> kill it by right-clicking on the process in the execution window and
> selecting "terminate." It appears to die within NetBeans but when I start
> it, the SocketServer instance complains that the port is not available. The
> Windows command "netstat -a" confirms that there is still a process
> listening at the port, and Windows Task Manager also shows a java.exe
> process running. If I kill that java.exe process from the Task Manager, then
> everything is ok again -- I can restart my program and listen on the port
> again.
>
> What is the right way to kill a program like mine, so that it releases the
> port?
>
> Thanks,
>
> John
> (remove the pachyderm to reply)
>
>

Why not listen for a specific 'shutdown' message over your socket?

Forcibly killing a process isn't guaranteed (or even likely) to release
resources like your socket, and in the case of a virtual machine (such
as the JVM) it doesn't even kill the real process, just the process
inside the VM, as you note in your post.

--
[Ross A. Bamford] [ross AT the.website.domain]
Roscopeco Open Tech ++ Open Source + Java + Apache + CMF
http://www.roscopec0.f9.co.uk/ + info@xxxxxxxxxxxxxxxxxx


.



Relevant Pages

  • the right way to kill a java thread on Windows?
    ... the SocketServer instance complains that the port is not available. ... Windows command "netstat -a" confirms that there is still a process ... If I kill that java.exe process from the Task Manager, ...
    (comp.lang.java.programmer)
  • Re: Changing defautl ftp port
    ... the only thing is that kill -HUP inetd doesn't work for me ... > with Windows is it possible to mention the port (I read the help and ... and then connect hostname port ...
    (comp.unix.solaris)
  • generally, go lift a frog
    ... excuses the barbers frantically, Pauline won't kill any hollow ... windows. ... Dave weekly creeps them too. ...
    (rec.pets.cats.anecdotes)
  • <<SASSER Removal instructions>>
    ... Vulnerable Windows 2000 and Windows XP machines may have the LSASS.EXE ... installation of the patch as well as removal of the worm. ... Kill any process starting with 'avserv' (i.e. avserve.exe, ...
    (microsoft.public.backoffice.smallbiz)
  • <<SASSER Removal instructions>>
    ... Vulnerable Windows 2000 and Windows XP machines may have the LSASS.EXE ... installation of the patch as well as removal of the worm. ... Kill any process starting with 'avserv' (i.e. avserve.exe, ...
    (microsoft.public.backoffice.smallbiz2000)