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


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

Re: synchronized methods "under the hood"

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-in-01.newsfeed.easynews.com!easynews!core-easynews-01!easynews.com!en-nntp-07.dc1.easynews.com.POSTED!not-for-mail
From Roedy Green <see_website@mindprod.com.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: synchronized methods "under the hood"
Organization Canadian Mind Products
Reply-To Roedy Green <see_website@mindprod.com.invalid>
Message-ID <gbdej8tqq2qa7qtq05hqo7mpobs3tkvplc@4ax.com> (permalink)
References <7d23ce84-c209-43a2-bf88-2d112ce21a2e@googlegroups.com> <fpkcj8l7bqvg5qoki7m0b4dom3ha0qfp0f@4ax.com> <apnan8FdajU1@mid.dfncis.de>
User-Agent ForteAgent/7.00.32.1200
MIME-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 8bit
Lines 23
X-Complaints-To abuse@easynews.com
X-Complaints-Info Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date Wed, 06 Mar 2013 04:28:58 -0800
X-Received-Bytes 2080
Xref csiph.com comp.lang.java.programmer:22735

Show key headers only | View raw


On Tue, 05 Mar 2013 23:44:34 +0100, Sven Köhler
<remove-sven.koehler@gmail.com> wrote, quoted or indirectly quoted
someone who said :

>Such test and set methods are implemented in Java's Atomic* classes
>(e.g. AtomicInteger). However, you need more than that to implement a
>proper mutex. What I would call a proper mutex puts a thread to sleep,
>if it cannot lock the mutex. To do that, you need to tell the kernel
>that the thread is suspended

I thought he was asking about what happens at the hardware level.
Thread context switching I think is still done with software.

Back in the 1990s I wrote a package in C to allow threads that ran on
a single CPU. Threads had to be well behaved and call "have a
conscience" periodically. It was remarkably simple, just save and
restore contexts.  It is quite bit more complicated when you can
interrupt threads in mid instruction or when you have multiple CPUs.
-- 
Roedy Green Canadian Mind Products http://mindprod.com
One thing I love about having a website, is that when I complain about
something, I only have to do it once. It saves me endless hours of 
grumbling.

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


Thread

synchronized methods "under the hood" bob smith <bob@coolfone.comze.com> - 2013-03-05 09:02 -0800
  Re: synchronized methods "under the hood" Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-03-05 09:15 -0800
  Re: synchronized methods "under the hood" Jan Burse <janburse@fastmail.fm> - 2013-03-05 18:59 +0100
    Re: synchronized methods "under the hood" Jan Burse <janburse@fastmail.fm> - 2013-03-05 19:16 +0100
    Re: synchronized methods "under the hood" Jan Burse <janburse@fastmail.fm> - 2013-03-06 15:24 +0100
  Re: synchronized methods "under the hood" Roedy Green <see_website@mindprod.com.invalid> - 2013-03-05 12:19 -0800
    Re: synchronized methods "under the hood" Sven Köhler <remove-sven.koehler@gmail.com> - 2013-03-05 23:44 +0100
      Re: synchronized methods "under the hood" Roedy Green <see_website@mindprod.com.invalid> - 2013-03-06 04:28 -0800
        Re: synchronized methods "under the hood" Jan Burse <janburse@fastmail.fm> - 2013-03-06 15:20 +0100

csiph-web