0

Suppose I have a stateless session bean which is synchronized by the app server and I declare a StringBuilder as a class member(non-static). Is it also synchronized? Or do I have to synchonize myself?

Krishna Chaitanya
  • 2,533
  • 4
  • 40
  • 74
  • 2
    It is not synchronized. There's no magic there. However, if you happen to access it only through methods which are synchronized themselves, it may not matter. – Marko Topolnik Feb 03 '14 at 13:04
  • I would doubt your claim that an SLSB is synchronized by the container. The point of being stateless is that it *doesn't* need synchronization. – Marko Topolnik Feb 03 '14 at 13:06
  • `Variables` are not synchronised. Access to them via `functions/blocks` can be synchronized, as far as i know :) – Aman Arora Feb 03 '14 at 13:11
  • http://stackoverflow.com/questions/1935178/correct-usage-of-stateful-beans-with-servlets/1935476#1935476 post says that an SLSB is synchronized by the app server. – Krishna Chaitanya Feb 03 '14 at 13:12
  • 2
    SLSB beans are not synchronized in terms of Java. Just the container doesn't allow two clients to use the same instance simultaneously. – Adrian Mitev Feb 04 '14 at 06:32

0 Answers0