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


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

Re: A question about synchronized threads

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!weretis.net!feeder5.news.weretis.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Robert Klemme <shortcutter@googlemail.com>
Newsgroups comp.lang.java.programmer
Subject Re: A question about synchronized threads
Date Sat, 30 Apr 2011 17:34:00 +0200
Lines 43
Message-ID <922offF2frU1@mid.individual.net> (permalink)
References <3f249d87-aaf8-4732-9ee8-fd112cf82553@f31g2000pri.googlegroups.com> <ipemsm$7nc$1@news.albasani.net> <8b7289b0-2b52-44f9-96a9-fe1d2661de11@k3g2000prl.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding quoted-printable
X-Trace individual.net y6tRIRcrAi/Beog3BDA/hAepZNud8zQtZ8bIT82CYSWSte0Yg=
Cancel-Lock sha1:sEY9DaB+iUCv6MlU040TwqcIDc0=
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10
In-Reply-To <8b7289b0-2b52-44f9-96a9-fe1d2661de11@k3g2000prl.googlegroups.com>
X-Antivirus avast! (VPS 110430-0, 30.04.2011), Outbound message
X-Antivirus-Status Clean
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3315

Show key headers only | View raw


On 29.04.2011 18:12, byhesed wrote:
> On 4월30일, 오전12시53분, Lew<no...@lewscanon.com>  wrote:

>> What do you mean by "better"?  What precisely is not the way you want it?
>> What is your standard of effectuality?

> If too much spaces are marked as critical regions,
> then the program will not be optimized.
> It wastes too much time in waiting for obtaining a right to access
> critical regions.
>
> So, in my question, better means optimization when using threads.

There is no one size fits all answer to that question.  It completely 
depends on the nature of your application.  For example, if read 
accesses vastly outnumber write accesses you will get significant 
improvements by using read write locks.  If it is the other way round 
you won't notice a big difference between using "synchronized" and a 
read write lock (because most of the time the exclusive write lock will 
be used).

In other situations not sharing mutable state (i.e. copying mutable 
state or using immutable state) might be the best solution.  Or you use 
a thread safe data structure such as copy on write list.

There is a whole, big toolbox for writing scalable thread safe 
applications.  Eric has it exactly right with his suggestion because the 
nature of the state (shared, not shared, mutable, immutable) is the 
important aspect to reason about.  I recommend reading Doug Lea's 
excellent book on the matter.

Kind regards

	robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

Back to comp.lang.java.programmer | Previous | NextNext in thread | Find similar


Thread

Re: A question about synchronized threads Robert Klemme <shortcutter@googlemail.com> - 2011-04-30 17:34 +0200
  Re: A question about synchronized threads byhesed <byhesed@gmail.com> - 2011-04-30 09:12 -0700
  Re: A question about synchronized threads Deeyana <d.awlberg@hotmail.invalid> - 2011-04-30 19:43 +0000
    Re: A question about synchronized threads Lew <noone@lewscanon.com> - 2011-05-03 18:47 -0400
      Re: A question about synchronized threads Deeyana <d.awlberg@hotmail.invalid> - 2011-05-04 00:12 +0000
        Re: A question about synchronized threads Lew <noone@lewscanon.com> - 2011-05-03 23:35 -0400
          Re: A question about synchronized threads Deeyana <d.awlberg@hotmail.invalid> - 2011-05-04 07:05 +0000
            Re: A question about synchronized threads Lew <noone@lewscanon.com> - 2011-05-04 12:44 -0400
              Re: A question about synchronized threads Deeyana <d.awlberg@hotmail.invalid> - 2011-05-04 19:57 +0000

csiph-web