177 |
|
} |
178 |
|
} |
179 |
|
|
180 |
+ |
|
181 |
+ |
/** |
182 |
+ |
* getRejectedExecutionHandler returns handler in constructor if not set |
183 |
+ |
*/ |
184 |
+ |
public void testGetRejectedExecutionHandler() { |
185 |
+ |
RejectedExecutionHandler h = new NoOpREHandler(); |
186 |
+ |
ThreadPoolExecutor p = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10), h); |
187 |
+ |
assertSame(h, p.getRejectedExecutionHandler()); |
188 |
+ |
p.shutdown(); |
189 |
+ |
joinPool(p); |
190 |
+ |
} |
191 |
+ |
|
192 |
+ |
/** |
193 |
+ |
* setRejectedExecutionHandler sets the handler returned by |
194 |
+ |
* getRejectedExecutionHandler |
195 |
+ |
*/ |
196 |
+ |
public void testSetRejectedExecutionHandler() { |
197 |
+ |
ThreadPoolExecutor p = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
198 |
+ |
RejectedExecutionHandler h = new NoOpREHandler(); |
199 |
+ |
p.setRejectedExecutionHandler(h); |
200 |
+ |
assertSame(h, p.getRejectedExecutionHandler()); |
201 |
+ |
p.shutdown(); |
202 |
+ |
joinPool(p); |
203 |
+ |
} |
204 |
+ |
|
205 |
+ |
|
206 |
+ |
/** |
207 |
+ |
* setRejectedExecutionHandler(null) throws NPE |
208 |
+ |
*/ |
209 |
+ |
public void testSetRejectedExecutionHandlerNull() { |
210 |
+ |
ThreadPoolExecutor p = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
211 |
+ |
try { |
212 |
+ |
p.setRejectedExecutionHandler(null); |
213 |
+ |
shouldThrow(); |
214 |
+ |
} catch (NullPointerException success) { |
215 |
+ |
} finally { |
216 |
+ |
joinPool(p); |
217 |
+ |
} |
218 |
+ |
} |
219 |
+ |
|
220 |
|
|
221 |
|
/** |
222 |
|
* getLargestPoolSize increases, but doesn't overestimate, when |