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


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

Re: "heartbeat" approach

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From Knute Johnson <nospam@knutejohnson.com>
Newsgroups comp.lang.java.programmer
Subject Re: "heartbeat" approach
Date Fri, 01 Feb 2013 08:40:35 -0800
Organization A noiseless patient Spider
Lines 18
Message-ID <kegr5i$i02$1@dont-email.me> (permalink)
References <0e900395-a38a-44a1-a5bf-01cc781c8728@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Fri, 1 Feb 2013 16:40:18 +0000 (UTC)
Injection-Info mx05.eternal-september.org; posting-host="aba33539224e5c782fe0c4053f7756fd"; logging-data="18434"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/nFU75Sa9UHeIZXv3T0Gxb"
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130107 Thunderbird/17.0.2
In-Reply-To <0e900395-a38a-44a1-a5bf-01cc781c8728@googlegroups.com>
Cancel-Lock sha1:3KSdA9gRNmKd6rD6hPSq7K7iR0I=
Xref csiph.com comp.lang.java.programmer:21958

Show key headers only | View raw


On 2/1/2013 8:11 AM, bob smith wrote:
> What is the best way to handle a situation where you want a socket to
> send a "heartbeat" every ten minutes?  I was thinking it would be
> simple to have a single thread do all the "heartbeat" sending.
>
> However, that means there could be multiple threads writing to one
> socket.  Do I need to do anything special to have multiple threads
> writing to one socket?  Is there a better way?
>
> Thanks.
>

Just synchronize on the Socket or the OutputStream.  The cost of
synchronizing in that case would be very low.

-- 

Knute Johnson

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


Thread

"heartbeat" approach bob smith <bob@coolfone.comze.com> - 2013-02-01 08:11 -0800
  Re: "heartbeat" approach Knute Johnson <nospam@knutejohnson.com> - 2013-02-01 08:40 -0800
  Re: "heartbeat" approach Arne Vajhøj <arne@vajhoej.dk> - 2013-02-01 17:46 -0500
    Re: "heartbeat" approach Robert Klemme <shortcutter@googlemail.com> - 2013-02-02 00:13 +0100
      Re: "heartbeat" approach Arne Vajhøj <arne@vajhoej.dk> - 2013-02-01 18:21 -0500
      Re: "heartbeat" approach Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-02-03 06:51 -0400
  Re: "heartbeat" approach Roedy Green <see_website@mindprod.com.invalid> - 2013-02-01 15:20 -0800

csiph-web