Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Sebastian Newsgroups: comp.lang.java.programmer Subject: Re: Concurrent bidirectional one-to-many map? Date: Wed, 11 May 2011 10:51:54 +0200 Organization: albasani.net Lines: 27 Message-ID: References: <08586289-8935-4532-93d0-e8c7dd45cb24@c1g2000yqe.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net 8PVVHo7X+At3Ac1WjOa2dnQ++G+fSgUmVqMaADXFcC+tqmRHqt+T5fkTjxANBmfqBbDC4Qb104sSFiolB6s48+MtMsnBk3RlhcSikPtT8AzFr2/Y3WeXfIcEvfr5biee NNTP-Posting-Date: Wed, 11 May 2011 08:51:55 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="8JI/DYCkdUwP60CskHxhPmW9yxqHgeFV8fMceBSaqT2uGoApWjJEFS6PDShwFOU/wBzsv/ba7Yg0Mh+Budeq90u+sbwqJvl2MxzjEwZ5EEWyCj2Lmlr16EiQTQyIwZJv"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 In-Reply-To: Cancel-Lock: sha1:YO3D2ino4KA9zo7y0TOzofcXdqs= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3957 Am 11.05.2011 10:09, schrieb Sebastian: > > > Here's a bit of the WorkspaceManager code referred to above: > > public void closeWorkspace( UUID id ) > { > writeLock.lock(); // <<<<<<<<<<< necessary ? > try { > Workspace wp = wpMap.remove( id ); > ... As afterthought to my immediately preceding post, let me add that it would be nice if we could process unrelated workspaces in parallel. How about having a ReentrantReadWriteLock associated with each workspace, and using themlike this: Workspace wp = wpMap.get( id ); wp.writeLock.lock(); try { wpMap.remove( id ); ... Wouldn't this improve things? -- Sebastian