S
Simon Eichenauer
Hi,
I´ve got a question about thread safety within servlet applications.
I know that, for example within a servlet or a struts action, you
shouldn´t use member variables because within the virtual machine
only one instance of each servlet / action exists (or at least the member
variables exist only once and aren´t put on the thread stack). But what
about member variables declared within
classes that are used within servlet or action methods? Are they threadsafe?
For example:
Action
execute() {
Test test = new Test();
test.setMemberVariable("test");
}
Class Test {
private String member; // Threadsafe ???
public void setMemberVariable(String test) {
member = test;
}
}
Maybe it´s really stupid but I just couldn´t find any hint.
Regards,
Simon
I´ve got a question about thread safety within servlet applications.
I know that, for example within a servlet or a struts action, you
shouldn´t use member variables because within the virtual machine
only one instance of each servlet / action exists (or at least the member
variables exist only once and aren´t put on the thread stack). But what
about member variables declared within
classes that are used within servlet or action methods? Are they threadsafe?
For example:
Action
execute() {
Test test = new Test();
test.setMemberVariable("test");
}
Class Test {
private String member; // Threadsafe ???
public void setMemberVariable(String test) {
member = test;
}
}
Maybe it´s really stupid but I just couldn´t find any hint.
Regards,
Simon