If you use this class with several threads then the param and sb should also be marked as volatile or am i wrong?? private double param = Math.random(); private StringBuilder sb = new StringBuilder();