1public class DataHolder
2{
3 private static String dataString;
4
5 public static String getDataString
6 {
7 return dataString;
8 }
9
10 public static void setString(String dataString)
11 {
12 this.dataString = dataString;
13 }
14}
1class SomeClass {
2 private static Data data;
3
4 public static void setData(String data) {
5 data = new Data(data);
6 }
7
8 public static String getData() {
9 return data.toString();
10 }
11}
12
13class Data {
14 private String data;
15
16 public Data(String data) {
17 this.data = data;
18 }
19
20 public String toString() {
21 return data;
22 }
23}
1public class DataHolder{
2 private static String dataString;
3 public static String getDataString(){
4 synchronized(DataHolder.class){
5 return DataHolder.dataString;
6 }
7 }
8
9 public static void setString(String dataString){
10 synchronized(DataHolder.class){
11 DataHolder.dataString = dataString;
12 }
13 }
14}