Return-Path: X-Original-To: apmail-commons-dev-archive@www.apache.org Delivered-To: apmail-commons-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 960E09AF9 for ; Sat, 3 Mar 2012 00:01:52 +0000 (UTC) Received: (qmail 78726 invoked by uid 500); 3 Mar 2012 00:01:52 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 78590 invoked by uid 500); 3 Mar 2012 00:01:52 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 78582 invoked by uid 99); 3 Mar 2012 00:01:51 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Mar 2012 00:01:51 +0000 Received: from localhost (HELO [10.0.1.3]) (127.0.0.1) (smtp-auth username marcosperanza, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Mar 2012 00:01:51 +0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1251.1) Subject: Re: [Graph] Test problems after last commit From: Marco Speranza In-Reply-To: Date: Sat, 3 Mar 2012 01:01:48 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <40CCE98F-30AD-4CAB-A0D6-39CAFD48C86E@apache.org> References: <7D559666-BDAF-4B0B-854B-E2CCF7B59165@apache.org> <55261764-7F6E-4DD5-BBFD-6CABF5940E89@apache.org> <8A601E86-5D6C-46C0-90F2-369907594D8E@apache.org> To: "Commons Developers List" X-Mailer: Apple Mail (2.1251.1) >>=20 >> furthermore there is another problem: with handler is not possible to = use correctly synchronization block like this >>=20 >> =3D=3D=3D=3D >> Graph g =3D CommonsGraph.synchronize(g_); >> ... >> synchronized(g) { >> for ( BaseLabeledVertex v2 : g.getVertices() ) >> { >> // do somethings >> } >> } >> =3D=3D=3D=3D >=20 > sorry I don't understand what you meant/intend to do I'm trying to explain better. the method getVertices return an Iterator. = In a multi-thread environment you have to ensure that during the 'for' = execution the [graph] data structure remains consistent.=20 Also for java collection is the same = [http://docs.oracle.com/javase/6/docs/api/java/util/Collections.html#synch= ronizedCollection(java.util.Collection)] So if we use a proxy/handler there is no way to "export" the mutex/lock = variable used into handler class. In our CommonsGraph the variable this.lock is private and is non = possible to export out of the method, so the user can not utilize the = lock to synchronize his block. =3D=3D=3D public Object invoke( Object proxy, Method method, Object[] args = ) throws Throwable { if ( synchronizedMethods.contains( method ) ) { try { synchronized ( this.lock ) { return method.invoke( synchronizedMethods, args = ); } } catch ( InvocationTargetException e ) { throw e.getTargetException(); } } return method.invoke( synchronizedMethods, args ); } =3D=3D=3D ciao -- Marco Speranza Google Code: http://code.google.com/u/marco.speranza79/ Il giorno 03/mar/2012, alle ore 00:45, Simone Tripodi ha scritto: >> furthermore there is another problem: with handler is not possible to = use correctly synchronization block like this >>=20 >> =3D=3D=3D=3D >> Graph g =3D CommonsGraph.synchronize(g_); >> ... >> synchronized(g) { >> for ( BaseLabeledVertex v2 : g.getVertices() ) >> { >> // do somethings >> } >> } >> =3D=3D=3D=3D >=20 > sorry I don't understand what you meant/intend to do >=20 >> I really think that a synchronized wrapper it's the best solution. >>=20 >> WDYT? >=20 > they sucks because we have to keep them updated while , but if there > are not alternatives... > -Simo >=20 > http://people.apache.org/~simonetripodi/ > http://simonetripodi.livejournal.com/ > http://twitter.com/simonetripodi > http://www.99soft.org/ >=20 > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org > For additional commands, e-mail: dev-help@commons.apache.org >=20 --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org