0

Does creating a StringBuffer testing= null;

testing = new StringBuffer("Thread Safe ");

inside a static method . Does the same reference of stringbuffer gets modified by thread every time in case multiple threads are calling the function at the same time.

public static StringBuffer test(String string) {       
    StringBuffer testing = null;
    testing = new StringBuffer("Thread Safe ");
    return testing;
}
Shubham
  • 1,755
  • 3
  • 17
  • 33
Akash
  • 1
  • Possible duplicate of [Threadsafe static initialization of ExecutorService](https://stackoverflow.com/questions/45009918/threadsafe-static-initialization-of-executorservice) – Dark Knight Jun 12 '19 at 11:20
  • 4
    If it's a local variable within the method, then each caller (and thus thread) will get their own object. – vlumi Jun 12 '19 at 11:22

0 Answers0