You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by fnuzbit <fn...@googlemail.com> on 2011/04/05 16:26:21 UTC

5.2.x page instance variables & thread safety

HI All,

I was reading the release notes for 5.2.0 about the removal of the page 
pool and just wanted to clarify a threading issue:

Am I right in thinking this is not thread safe in a 5.2.x page/component:

private String foo;

public String getFoo(){
     return foo;
}
public void setFoo(String foo){
     this.foo = foo;
}


but it /is/ thread safe if I annotate it with the @Property instead:

@Property
private String foo;



Thanks in advance!

Jack






Re: 5.2.x page instance variables & thread safety

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 05 Apr 2011 11:26:21 -0300, fnuzbit <fn...@googlemail.com> wrote:

> HI All,

Hi!

> private String foo;
>
> public String getFoo(){
>      return foo;
> }
> public void setFoo(String foo){
>      this.foo = foo;
> }

This is thread-safe as any access to the field itself (reading or writing)  
is replaced internally by a per-thread Map. In other words, it's perfectly  
thread-safe.

> but it /is/ thread safe if I annotate it with the @Property instead:
>
> @Property
> private String foo;

AFAIK, using @Property generates the same bytecode as simple getters and  
setters.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org