Re: the right way to kill a java thread on Windows?
- From: Ross Bamford <ross@xxxxxxxxxxxx>
- Date: Sat, 30 Apr 2005 00:01:05 +0100
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
.
- References:
- Prev by Date: Re: parse int from string
- Next by Date: Re: Create InetAddress from a String.
- Previous by thread: the right way to kill a java thread on Windows?
- Next by thread: Re: the right way to kill a java thread on Windows?
- Index(es):
Relevant Pages
|
|