From: | Felipe Schnack <felipes(at)ritterdosreis(dot)br> |
---|---|
To: | pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: synchronized code [Viruschecked] |
Date: | 2003-01-08 19:16:47 |
Message-ID: | 1042053407.12254.124.camel@desenv1.ritterdosreis.br |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Yes, good java programmers use lots of StringBuffers :-)
But about Statement in threaded use: this is discouraged by the spec
or it isn't actually supported?
On Wed, 2003-01-08 at 17:04, Patric Bechtel wrote:
> On 08 Jan 2003 16:43:11 -0200, Felipe Schnack wrote:
>
> > I'm quite worried with the amount of synch'd code in our jdbc driver
> >code, we all know this is a very costly operation in Java.
> > As far as I could see from the sources, the sole objective of these
> >calls are to avoid two processes accessing the same shared StringBuffer
> >we use. The strangest thing, IMHO, is that every time we use this
> >buffer, we are calling setLength(0) or, in plain english, resetting this
> >buffer. Is just me the paranoid or this isn't helping performance at
> >all? As I understand java, object creating is a very cheap operation
> >these days (in the old days it was slow), but synch'ing is VERY
> >costly...
>
> There's no reason to fear about synchronisation since Hotspot anymore. The
> lock, as only one process is building it, is definitely less work
> than the work the garbage collector has to do in a mark-sweep cycle to
> get rid of Stringbuffer over Stringbuffer (which would occur otherwise).
> That said, as the syncing is upon a Stringbuffer for EACH statement, and
> the statement class threaded use is discouraged anyway, we will probably
> never see code really running into this.
> As many many string operations are needed throughout the driver, the use
> of a sync'ed stringbuffer whenever bigger string operations are made
> is very wise and good style. Kudos here to the developer who made this...
> The only drawback is, for the developers, that they have to be a bit
> cautious with the use of it, not to produce deadlocks; but that's
> rather easy, as each and every statement has it's own and the statement
> class itself isn't that big.
>
> just my 0.02¬...
>
>
>
> sincerely,
>
> Patric Bechtel
> IPCON Informationssysteme
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
--
Felipe Schnack
Analista de Sistemas
felipes(at)ritterdosreis(dot)br
Cel.: (51)91287530
Linux Counter #281893
Centro Universitário Ritter dos Reis
http://www.ritterdosreis.br
ritter(at)ritterdosreis(dot)br
Fone/Fax.: (51)32303341
From | Date | Subject | |
---|---|---|---|
Next Message | Felipe Schnack | 2003-01-08 19:17:32 | Re: synchronized code |
Previous Message | Patric Bechtel | 2003-01-08 19:04:12 | Re: synchronized code [Viruschecked] |