Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #33272

Re: multithread client socket

Path csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: multithread client socket
Date Wed, 2 Dec 2015 10:54:33 -0500
Organization A noiseless patient Spider
Lines 19
Message-ID <n3n43i$uto$1@dont-email.me> (permalink)
References <cd5afdca-ada8-4c3e-b1da-c29fc8f7442e@googlegroups.com> <n3ksvl$683$2@dont-email.me> <4ab5709a-0b5d-4f1b-8b50-139828b5b76e@googlegroups.com> <n3n0s9$8ml$3@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Wed, 2 Dec 2015 15:52:18 -0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="858a9d65d95f4ea4d355bd116aa2cdbf"; logging-data="31672"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/1WNOdf8RtiO503DeLcT1O"
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0
In-Reply-To <n3n0s9$8ml$3@dont-email.me>
Cancel-Lock sha1:YG+S4eXqd7P1Exl9gRtEmmcZR7s=
Xref csiph.com comp.lang.java.programmer:33272

Show key headers only | View raw


On 12/2/2015 9:57 AM, Martin Gregorie wrote:
> [...]
> You should able see how many Sockets are open when the client falls over
> by using a static volatile int that:
>
> - is incremented each time a thread successfully opens a client socket
>
> - is decremented each time a thread successfully closes a client socket
>
> - gets its value written to stderr by the exception code triggered by
>    a client socket failing to open or close.

     Use an AtomicInteger, not a volatile int.  The latter is not
thread-safe (unless guarded by other synchronization, or unless it's
read by many threads but modified by only one).

-- 
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

multithread client socket Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2015-12-01 09:36 -0800
  Re: multithread client socket Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2015-12-01 10:12 -0800
  Re: multithread client socket Martin Gregorie <martin@address-in-sig.invalid> - 2015-12-01 19:38 +0000
    Re: multithread client socket Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2015-12-01 22:56 -0800
      Re: multithread client socket Martin Gregorie <martin@address-in-sig.invalid> - 2015-12-02 14:57 +0000
        Re: multithread client socket Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-12-02 10:54 -0500
          Re: multithread client socket Martin Gregorie <martin@address-in-sig.invalid> - 2015-12-02 19:18 +0000
          Re: multithread client socket Eric Douglas <e.d.programmer@gmail.com> - 2015-12-02 11:47 -0800
            Re: multithread client socket Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-12-02 15:30 -0500
              Re: multithread client socket Eric Douglas <e.d.programmer@gmail.com> - 2015-12-02 12:57 -0800

csiph-web