Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #33276
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2015-12-02 12:57 -0800 |
| References | (2 earlier) <4ab5709a-0b5d-4f1b-8b50-139828b5b76e@googlegroups.com> <n3n0s9$8ml$3@dont-email.me> <n3n43i$uto$1@dont-email.me> <a2aef40d-4926-4982-bd07-9d344c07a772@googlegroups.com> <n3nk96$2ea$1@dont-email.me> |
| Message-ID | <25bb2f22-ed4e-4a52-838d-6b261b8bc055@googlegroups.com> (permalink) |
| Subject | Re: multithread client socket |
| From | Eric Douglas <e.d.programmer@gmail.com> |
On Wednesday, December 2, 2015 at 3:31:07 PM UTC-5, Eric Sosman wrote: > - Use a plain int, but do all the reads and writes inside a block > (or entire method) that synchronizes on one object, > > - Use a volatile int, synchronizing around all writes and letting > the reads just rely on volatility to make the writes visible, or > > - Use an AtomicInteger, whose own methods provide all the necessary > synchronization and publication without further work on your part. Sounds like good info there, I'll keep it in mind. Normally my classes don't share any non-final info across threads, aside from the basic GUI thread managing the JTable kicking off a background thread to retrieve cell values. > "Seems to work" is just "I haven't noticed the failures yet." If > you want code that's more trustworthy than "Keep your fingers crossed," > you'll need a bit more care. It's not hard -- and if you're doing > multi-threaded stuff, you Really Really Should exercise care. Ha, yeah sometimes it's pretty hard to write the test case that will crash code. Sometimes you just say you know your system well enough to know how the code is used will never crash, ie client-server socket program crashes if we hit 1000 clients but will only ever be used here for 1 server and 1-3 clients.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll 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