Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!newsreader4.netcologne.de!news.netcologne.de!bcyclone04.am1.xlned.com!bcyclone04.am1.xlned.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'that?': 0.05; 'linux,': 0.07; 'socket': 0.07; '*is*': 0.09; 'happen.': 0.09; 'mess': 0.09; 'php,': 0.09; 'slow.': 0.09; 'worse': 0.09; 'cc:addr:python-list': 0.11; '>>': 0.16; 'java.': 0.16; 'skip:s 280': 0.16; 'subject:? - ': 0.16; 'subject:Pypy': 0.16; 'subject:threads': 0.16; 'turn,': 0.16; 'wraps': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'bit': 0.19; 'feb': 0.22; 'programming': 0.22; 'cc:addr:python.org': 0.22; 'java': 0.24; 'paul': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'header:In- Reply-To:1': 0.27; 'tried': 0.27; 'wonder': 0.29; 'message- id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'code': 0.31; '25,': 0.31; 'developers.': 0.31; 'idea,': 0.31; 'writes:': 0.31; 'checked': 0.32; 'quite': 0.32; 'url:python': 0.33; "i'd": 0.34; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'version': 0.36; 'really': 0.36; 'keyword': 0.36; 'much.': 0.36; 'url:listinfo': 0.36; 'doing': 0.36; 'method': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'pm,': 0.38; 'skip:& 20': 0.39; 'url:mail': 0.40; 'skip:u 10': 0.60; 'read': 0.60; 'tell': 0.60; 'love': 0.65; 'life': 0.66; 'analysis': 0.75; '2015': 0.84; 'lighter': 0.84; 'stm': 0.84; 'mistake': 0.91; 'mistakes': 0.93; 'subject:Are': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=qzN2yyn75/0eIxbtupF4bz1a71xJSpunPlh0A2H5mg0=; b=XmL3S7/+uEJ5PUT2mpdIzd2mpPP0b8spRX1zqAvmIo+5wTrjHjwbqOtgev5+PMrUqS nEgvOZQM7UEVgtv92uHrSNvNSc3UdafuYLcyCTUVgpdhVWUHxZdSq8FQWZUZTIR+qdFy kFsQSsTt5/JunCpSlHs8+ow9/5/g5WbN24TmFpMmWnggwn814UY+K71ynHnvgl1sYezU 7NfpoM15H3dxqIzj036BhPPFIujzbC7u4KaG3ih0FZUEO9dmuqwmrL908fzyyyCU6biP QoaG1GvQ5vywq0Fhm0XVhFnzC/I0dHBUHaqh09xsaL4WeA/YpwOwXzvh6kYL9CXeCkbI PWPg== MIME-Version: 1.0 X-Received: by 10.180.105.40 with SMTP id gj8mr37614977wib.67.1424842473747; Tue, 24 Feb 2015 21:34:33 -0800 (PST) In-Reply-To: <87zj82bm15.fsf@elektro.pacujo.net> References: <87fv9xdb22.fsf@jester.gateway.pace.com> <54ea7ff4$0$12983$c3e8da3$5496439d@news.astraweb.com> <87zj85bcyu.fsf@jester.gateway.pace.com> <87lhjpb89i.fsf@jester.gateway.pace.com> <87h9udb1eq.fsf@jester.gateway.pace.com> <87bnkkb22u.fsf@jester.gateway.pace.com> <87lhjnang1.fsf@jester.gateway.pace.com> <87bnkjenpp.fsf@elektro.pacujo.net> <8761aqamss.fsf@jester.gateway.pace.com> <87zj82bm15.fsf@elektro.pacujo.net> Date: Wed, 25 Feb 2015 13:34:33 +0800 Subject: Re: Are threads bad? - was: Future of Pypy? From: Marcos Almeida Azevedo To: Marko Rauhamaa Content-Type: multipart/alternative; boundary=f46d04428d168239eb050fe2fddf Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 105 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1424842476 news.xs4all.nl 2950 [2001:888:2000:d::a6]:36219 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 9156 X-Received-Body-CRC: 589176552 Xref: csiph.com comp.lang.python:86375 --f46d04428d168239eb050fe2fddf Content-Type: text/plain; charset=UTF-8 On Wed, Feb 25, 2015 at 1:25 PM, Marko Rauhamaa wrote: > Paul Rubin : > > > Marko Rauhamaa writes: > >> So why lock categorically like that? Java has a handy "synchronized" > >> keyword that wraps the whole method in "with self.lock". ... > >> Unfortunately, that deep locking analysis *is* required at every turn, > >> and mistakes *are* bound to happen. > > > > I wonder if synchronized was a mistake in Java. It confused me a lot > > when I tried to use it, but I never had to mess with it that much. I > > can't quite tell what your code is doing (why is it attempting a > > socket read with a lock held) and I'd be interested to see what an STM > > version would look like. > > Synchronized methods are actually quite a powerful idea, but a bit > underappreciated by many Java developers. > > Synchronized methods in Java really makes programming life simpler. But I think it is standard practice to avoid this if there is a lighter alternative as synchronized methods are slow. Worse case I used double checked locking. > > > Marko > -- > https://mail.python.org/mailman/listinfo/python-list > -- Marcos | I love PHP, Linux, and Java --f46d04428d168239eb050fe2fddf Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On Wed, Feb 25, 2015 at 1:25 PM, Marko Rauhamaa <<= a href=3D"mailto:marko@pacujo.net" target=3D"_blank">marko@pacujo.net&g= t; wrote:
Paul Rubin <no.email@= nospam.invalid>:

> Marko Rauhamaa <marko@pacujo.ne= t> writes:
>> So why lock categorically like that? Java has a handy "synchr= onized"
>> keyword that wraps the whole method in "with self.lock".= ...
>> Unfortunately, that deep locking analysis *is* required at every t= urn,
>> and mistakes *are* bound to happen.
>
> I wonder if synchronized was a mistake in Java. It confused me a lot > when I tried to use it, but I never had to mess with it that much. I > can't quite tell what your code is doing (why is it attempting a > socket read with a lock held) and I'd be interested to see what an= STM
> version would look like.

Synchronized methods are actually quite a powerful idea, but a bit
underappreciated by many Java developers.


Synchronized methods in Java really makes = programming life simpler.=C2=A0 But I think it is standard practice to avoi= d this if there is a lighter alternative as synchronized methods are slow.= =C2=A0 Worse case I used double checked locking.
=C2=A0
=


Marko
--
https://mail.python.org/mailman/listinfo/python-list



--
Marcos | I love= PHP, Linux, and Java
--f46d04428d168239eb050fe2fddf--