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


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

Re: multithread client socket

Newsgroups comp.lang.java.programmer
Date 2015-12-02 11:47 -0800
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> <n3n43i$uto$1@dont-email.me>
Message-ID <a2aef40d-4926-4982-bd07-9d344c07a772@googlegroups.com> (permalink)
Subject Re: multithread client socket
From Eric Douglas <e.d.programmer@gmail.com>

Show all headers | View raw


On Wednesday, December 2, 2015 at 10:55:04 AM UTC-5, Eric Sosman wrote:
>      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).

but thread-recklessness is such fun, eh?  I just wrote a test program today that crashed with a ConcurrentModificationException.

I've actually never used the keyword volatile or an AtomicInteger.
A standard int seems to work fine to track the number of clients as long as it's a single server object doing all the tracking.

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