[concurrency-interest] Closing a socket from another thread

Shaffer, Darron Darron_Shaffer at stercomm.com
Tue Dec 19 13:11:22 EST 2006


This is a pain before JDK 1.4, because every JVM has its own little
quirks.  In fact, for at least one 1.3 JVM closing a ServerSocket from a
different thread would trigger a bug causing some future accepted
sockets to be handed to the wrong ServerSocket!
 
However, in 1.4 with the arrival of NIO the SocketChannel versions of
sockets have much better specifications of thread behavior.  Its now
supposed to just work, causing any threads blocked on the closed sockets
to receive an exception.  However, I haven't tested this extensively
because with NIO I avoid all blocking operations and don't have to do
this sort of thing.

________________________________

From: concurrency-interest-bounces at cs.oswego.edu
[mailto:concurrency-interest-bounces at cs.oswego.edu] On Behalf Of Peter
Kovacs
Sent: Tuesday, December 19, 2006 7:30 AM
To: Concurrency-interest at cs.oswego.edu
Subject: [concurrency-interest] Closing a socket from another thread


Hi, 

Anyone has an idea/experience how safe it is to close a socket from
another thread. Are there any utility classes which help me close a
socket safely? 

Thanks 

Peter 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20061219/36100cb7/attachment.html 


More information about the Concurrency-interest mailing list