36 import java.util.concurrent.atomic.AtomicInteger; |
36 import java.util.concurrent.atomic.AtomicInteger; |
37 import java.util.logging.Logger; |
37 import java.util.logging.Logger; |
38 |
38 |
39 |
39 |
40 public class LoggerResourceBundleRace extends RacingThreadsTest { |
40 public class LoggerResourceBundleRace extends RacingThreadsTest { |
41 private final static int N_LOOPS = 500000; // # of race loops |
41 private static final int N_LOOPS = 500000; // # of race loops |
42 private final static int N_SECS = 15; // # of secs to run test |
42 private static final int N_SECS = 15; // # of secs to run test |
43 // # of parallel threads; must match number of MyResources inner classes |
43 // # of parallel threads; must match number of MyResources inner classes |
44 private final static int N_THREADS = 3; |
44 private static final int N_THREADS = 3; |
45 |
45 |
46 private final static String LOGGER_PREFIX = "myLogger-"; |
46 private static final String LOGGER_PREFIX = "myLogger-"; |
47 private final static String RESOURCE_PREFIX |
47 private static final String RESOURCE_PREFIX |
48 = "LoggerResourceBundleRace$MyResources"; |
48 = "LoggerResourceBundleRace$MyResources"; |
49 // these counters are AtomicInteger since any worker thread can increment |
49 // these counters are AtomicInteger since any worker thread can increment |
50 private final static AtomicInteger iaeCnt = new AtomicInteger(); |
50 private static final AtomicInteger iaeCnt = new AtomicInteger(); |
51 private final static AtomicInteger worksCnt = new AtomicInteger(); |
51 private static final AtomicInteger worksCnt = new AtomicInteger(); |
52 |
52 |
53 Logger dummy; // dummy Logger |
53 Logger dummy; // dummy Logger |
54 |
54 |
55 LoggerResourceBundleRace(String name, int n_threads, int n_loops, |
55 LoggerResourceBundleRace(String name, int n_threads, int n_loops, |
56 int n_secs) { |
56 int n_secs) { |
154 } |
154 } |
155 |
155 |
156 // N_THREADS above must match number of MyResources inner classes |
156 // N_THREADS above must match number of MyResources inner classes |
157 // |
157 // |
158 public static class MyResources0 extends ListResourceBundle { |
158 public static class MyResources0 extends ListResourceBundle { |
159 final static Object[][] contents = { |
159 static final Object[][] contents = { |
160 {"sample1", "translation #1 for sample1"}, |
160 {"sample1", "translation #1 for sample1"}, |
161 {"sample2", "translation #1 for sample2"}, |
161 {"sample2", "translation #1 for sample2"}, |
162 }; |
162 }; |
163 |
163 |
164 public Object[][] getContents() { |
164 public Object[][] getContents() { |
165 return contents; |
165 return contents; |
166 } |
166 } |
167 } |
167 } |
168 |
168 |
169 public static class MyResources1 extends ListResourceBundle { |
169 public static class MyResources1 extends ListResourceBundle { |
170 final static Object[][] contents = { |
170 static final Object[][] contents = { |
171 {"sample1", "translation #2 for sample1"}, |
171 {"sample1", "translation #2 for sample1"}, |
172 {"sample2", "translation #2 for sample2"}, |
172 {"sample2", "translation #2 for sample2"}, |
173 }; |
173 }; |
174 |
174 |
175 public Object[][] getContents() { |
175 public Object[][] getContents() { |
176 return contents; |
176 return contents; |
177 } |
177 } |
178 } |
178 } |
179 |
179 |
180 public static class MyResources2 extends ListResourceBundle { |
180 public static class MyResources2 extends ListResourceBundle { |
181 final static Object[][] contents = { |
181 static final Object[][] contents = { |
182 {"sample1", "translation #3 for sample1"}, |
182 {"sample1", "translation #3 for sample1"}, |
183 {"sample2", "translation #3 for sample2"}, |
183 {"sample2", "translation #3 for sample2"}, |
184 }; |
184 }; |
185 |
185 |
186 public Object[][] getContents() { |
186 public Object[][] getContents() { |