stringbuilder « Thread Safe « Java Thread Q&A

Home
Java Thread Q&A
1.concurrency
2.Development
3.Exception
4.Notify
5.Operation
6.Socket
7.State
8.synchronize
9.Thread Safe
10.ThreadPool
Java Thread Q&A » Thread Safe » stringbuilder 

1. Java StringBuilder and Thread Safety    stackoverflow.com

I am building up a String out of multiple pieces and want to use either StringBuffer or StringBuilder to do so. From the Java 5 docs, I see that StringBuilder is ...

2. Is that StringBuidler variable is thread safe in this code    stackoverflow.com

Consider the below struts Action class in which, I am using a StringBuilder variable inside the execute method. My question: Is the variable sb threadsafe or not?

public DemoAction extends Action
{
  ...

3. Making custom StringBuilder (or StringBuffer) - forget thread-safe / unsafe    coderanch.com

class MutableString { private char[] array = new char[10]; private int size = 0; public void add(String s) { ensureSize(size + s.length()); for (int i = 0; i < s.length(); i++) { array[size++] = s.charAt(i); } } private void ensureSize(int size) { if (size > array.length) { char[] array = new char[size]; // naive approach System.arraycopy(this.array, 0, array, 0, this.size); } ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.