48 |
|
|
49 |
|
|
50 |
|
/** |
51 |
< |
* execute successfully executes a runnable |
51 |
> |
* execute successfully executes a runnable |
52 |
|
*/ |
53 |
|
public void testExecute() throws InterruptedException { |
54 |
|
ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
61 |
|
} |
62 |
|
|
63 |
|
/** |
64 |
< |
* getActiveCount increases but doesn't overestimate, when a |
65 |
< |
* thread becomes active |
64 |
> |
* getActiveCount increases but doesn't overestimate, when a |
65 |
> |
* thread becomes active |
66 |
|
*/ |
67 |
|
public void testGetActiveCount() throws InterruptedException { |
68 |
|
ThreadPoolExecutor p2 = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
74 |
|
} |
75 |
|
|
76 |
|
/** |
77 |
< |
* prestartCoreThread starts a thread if under corePoolSize, else doesn't |
77 |
> |
* prestartCoreThread starts a thread if under corePoolSize, else doesn't |
78 |
|
*/ |
79 |
|
public void testPrestartCoreThread() { |
80 |
|
ThreadPoolExecutor p2 = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
89 |
|
} |
90 |
|
|
91 |
|
/** |
92 |
< |
* prestartAllCoreThreads starts all corePoolSize threads |
92 |
> |
* prestartAllCoreThreads starts all corePoolSize threads |
93 |
|
*/ |
94 |
|
public void testPrestartAllCoreThreads() { |
95 |
|
ThreadPoolExecutor p2 = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
102 |
|
} |
103 |
|
|
104 |
|
/** |
105 |
< |
* getCompletedTaskCount increases, but doesn't overestimate, |
106 |
< |
* when tasks complete |
105 |
> |
* getCompletedTaskCount increases, but doesn't overestimate, |
106 |
> |
* when tasks complete |
107 |
|
*/ |
108 |
|
public void testGetCompletedTaskCount() throws InterruptedException { |
109 |
|
ThreadPoolExecutor p2 = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
116 |
|
} |
117 |
|
|
118 |
|
/** |
119 |
< |
* getCorePoolSize returns size given in constructor if not otherwise set |
119 |
> |
* getCorePoolSize returns size given in constructor if not otherwise set |
120 |
|
*/ |
121 |
|
public void testGetCorePoolSize() { |
122 |
|
ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
125 |
|
} |
126 |
|
|
127 |
|
/** |
128 |
< |
* getKeepAliveTime returns value given in constructor if not otherwise set |
128 |
> |
* getKeepAliveTime returns value given in constructor if not otherwise set |
129 |
|
*/ |
130 |
|
public void testGetKeepAliveTime() { |
131 |
|
ThreadPoolExecutor p2 = new ThreadPoolExecutor(2, 2, 1000, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
209 |
|
|
210 |
|
|
211 |
|
/** |
212 |
< |
* getLargestPoolSize increases, but doesn't overestimate, when |
213 |
< |
* multiple threads active |
212 |
> |
* getLargestPoolSize increases, but doesn't overestimate, when |
213 |
> |
* multiple threads active |
214 |
|
*/ |
215 |
|
public void testGetLargestPoolSize() throws InterruptedException { |
216 |
|
ThreadPoolExecutor p2 = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
223 |
|
} |
224 |
|
|
225 |
|
/** |
226 |
< |
* getMaximumPoolSize returns value given in constructor if not |
227 |
< |
* otherwise set |
226 |
> |
* getMaximumPoolSize returns value given in constructor if not |
227 |
> |
* otherwise set |
228 |
|
*/ |
229 |
|
public void testGetMaximumPoolSize() { |
230 |
|
ThreadPoolExecutor p2 = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
233 |
|
} |
234 |
|
|
235 |
|
/** |
236 |
< |
* getPoolSize increases, but doesn't overestimate, when threads |
237 |
< |
* become active |
236 |
> |
* getPoolSize increases, but doesn't overestimate, when threads |
237 |
> |
* become active |
238 |
|
*/ |
239 |
|
public void testGetPoolSize() { |
240 |
|
ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
245 |
|
} |
246 |
|
|
247 |
|
/** |
248 |
< |
* getTaskCount increases, but doesn't overestimate, when tasks submitted |
248 |
> |
* getTaskCount increases, but doesn't overestimate, when tasks submitted |
249 |
|
*/ |
250 |
|
public void testGetTaskCount() throws InterruptedException { |
251 |
|
ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
257 |
|
} |
258 |
|
|
259 |
|
/** |
260 |
< |
* isShutDown is false before shutdown, true after |
260 |
> |
* isShutDown is false before shutdown, true after |
261 |
|
*/ |
262 |
|
public void testIsShutdown() { |
263 |
|
|
270 |
|
|
271 |
|
|
272 |
|
/** |
273 |
< |
* isTerminated is false before termination, true after |
273 |
> |
* isTerminated is false before termination, true after |
274 |
|
*/ |
275 |
|
public void testIsTerminated() throws InterruptedException { |
276 |
|
ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
285 |
|
} |
286 |
|
|
287 |
|
/** |
288 |
< |
* isTerminating is not true when running or when terminated |
288 |
> |
* isTerminating is not true when running or when terminated |
289 |
|
*/ |
290 |
|
public void testIsTerminating() throws InterruptedException { |
291 |
|
ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
354 |
|
} |
355 |
|
|
356 |
|
/** |
357 |
< |
* purge removes cancelled tasks from the queue |
357 |
> |
* purge removes cancelled tasks from the queue |
358 |
|
*/ |
359 |
|
public void testPurge() { |
360 |
|
ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
372 |
|
} |
373 |
|
|
374 |
|
/** |
375 |
< |
* shutDownNow returns a list containing tasks that were not run |
375 |
> |
* shutDownNow returns a list containing tasks that were not run |
376 |
|
*/ |
377 |
|
public void testShutDownNow() { |
378 |
|
ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
683 |
|
|
684 |
|
|
685 |
|
/** |
686 |
< |
* execute throws RejectedExecutionException |
687 |
< |
* if saturated. |
686 |
> |
* execute throws RejectedExecutionException if saturated. |
687 |
|
*/ |
688 |
|
public void testSaturatedExecute() { |
689 |
|
ThreadPoolExecutor p = |
705 |
|
} |
706 |
|
|
707 |
|
/** |
708 |
< |
* executor using CallerRunsPolicy runs task if saturated. |
708 |
> |
* executor using CallerRunsPolicy runs task if saturated. |
709 |
|
*/ |
710 |
|
public void testSaturatedExecute2() { |
711 |
|
RejectedExecutionHandler h = new ThreadPoolExecutor.CallerRunsPolicy(); |
731 |
|
} |
732 |
|
|
733 |
|
/** |
734 |
< |
* executor using DiscardPolicy drops task if saturated. |
734 |
> |
* executor using DiscardPolicy drops task if saturated. |
735 |
|
*/ |
736 |
|
public void testSaturatedExecute3() { |
737 |
|
RejectedExecutionHandler h = new ThreadPoolExecutor.DiscardPolicy(); |
756 |
|
} |
757 |
|
|
758 |
|
/** |
759 |
< |
* executor using DiscardOldestPolicy drops oldest task if saturated. |
759 |
> |
* executor using DiscardOldestPolicy drops oldest task if saturated. |
760 |
|
*/ |
761 |
|
public void testSaturatedExecute4() { |
762 |
|
RejectedExecutionHandler h = new ThreadPoolExecutor.DiscardOldestPolicy(); |
777 |
|
} |
778 |
|
|
779 |
|
/** |
780 |
< |
* execute throws RejectedExecutionException if shutdown |
780 |
> |
* execute throws RejectedExecutionException if shutdown |
781 |
|
*/ |
782 |
|
public void testRejectedExecutionExceptionOnShutdown() { |
783 |
|
ThreadPoolExecutor tpe = |
792 |
|
} |
793 |
|
|
794 |
|
/** |
795 |
< |
* execute using CallerRunsPolicy drops task on shutdown |
795 |
> |
* execute using CallerRunsPolicy drops task on shutdown |
796 |
|
*/ |
797 |
|
public void testCallerRunsOnShutdown() { |
798 |
|
RejectedExecutionHandler h = new ThreadPoolExecutor.CallerRunsPolicy(); |
809 |
|
} |
810 |
|
|
811 |
|
/** |
812 |
< |
* execute using DiscardPolicy drops task on shutdown |
812 |
> |
* execute using DiscardPolicy drops task on shutdown |
813 |
|
*/ |
814 |
|
public void testDiscardOnShutdown() { |
815 |
|
RejectedExecutionHandler h = new ThreadPoolExecutor.DiscardPolicy(); |
827 |
|
|
828 |
|
|
829 |
|
/** |
830 |
< |
* execute using DiscardOldestPolicy drops task on shutdown |
830 |
> |
* execute using DiscardOldestPolicy drops task on shutdown |
831 |
|
*/ |
832 |
|
public void testDiscardOldestOnShutdown() { |
833 |
|
RejectedExecutionHandler h = new ThreadPoolExecutor.DiscardOldestPolicy(); |
876 |
|
} |
877 |
|
|
878 |
|
/** |
879 |
< |
* setMaximumPoolSize(int) throws IllegalArgumentException if |
880 |
< |
* given a value less the core pool size |
879 |
> |
* setMaximumPoolSize(int) throws IllegalArgumentException if |
880 |
> |
* given a value less the core pool size |
881 |
|
*/ |
882 |
|
public void testMaximumPoolSizeIllegalArgumentException() { |
883 |
|
ThreadPoolExecutor tpe = |
895 |
|
} |
896 |
|
|
897 |
|
/** |
898 |
< |
* setMaximumPoolSize throws IllegalArgumentException |
899 |
< |
* if given a negative value |
898 |
> |
* setMaximumPoolSize throws IllegalArgumentException |
899 |
> |
* if given a negative value |
900 |
|
*/ |
901 |
|
public void testMaximumPoolSizeIllegalArgumentException2() { |
902 |
|
ThreadPoolExecutor tpe = |
915 |
|
|
916 |
|
|
917 |
|
/** |
918 |
< |
* setKeepAliveTime throws IllegalArgumentException |
919 |
< |
* when given a negative value |
918 |
> |
* setKeepAliveTime throws IllegalArgumentException |
919 |
> |
* when given a negative value |
920 |
|
*/ |
921 |
|
public void testKeepAliveTimeIllegalArgumentException() { |
922 |
|
ThreadPoolExecutor tpe = |