93 |
|
finally { lock.unlock(); } |
94 |
|
} |
95 |
|
public V get(long timeout, TimeUnit unit) |
96 |
< |
throws InterruptedException, ExecutionException, TimeoutException{ |
96 |
> |
throws InterruptedException, ExecutionException, TimeoutException { |
97 |
|
long nanos = unit.toNanos(timeout); |
98 |
|
lock.lock(); |
99 |
|
try { |
176 |
|
|
177 |
|
} |
178 |
|
|
179 |
< |
static class FailingThreadFactory implements ThreadFactory{ |
179 |
> |
static class FailingThreadFactory implements ThreadFactory { |
180 |
|
int calls = 0; |
181 |
< |
public Thread newThread(Runnable r){ |
181 |
> |
public Thread newThread(Runnable r) { |
182 |
|
if (++calls > 1) return null; |
183 |
|
return new Thread(r); |
184 |
|
} |
195 |
|
public void run() { |
196 |
|
try { |
197 |
|
Thread.sleep(SHORT_DELAY_MS); |
198 |
< |
} catch (InterruptedException e){ |
198 |
> |
} catch (InterruptedException e) { |
199 |
|
threadUnexpectedException(); |
200 |
|
} |
201 |
|
} |
202 |
|
}); |
203 |
|
Thread.sleep(SMALL_DELAY_MS); |
204 |
< |
} catch (InterruptedException e){ |
204 |
> |
} catch (InterruptedException e) { |
205 |
|
unexpectedException(); |
206 |
|
} |
207 |
|
joinPool(p1); |
217 |
|
p2.execute(new MediumRunnable()); |
218 |
|
try { |
219 |
|
Thread.sleep(SHORT_DELAY_MS); |
220 |
< |
} catch (Exception e){ |
220 |
> |
} catch (Exception e) { |
221 |
|
unexpectedException(); |
222 |
|
} |
223 |
|
assertEquals(1, p2.getActiveCount()); |
262 |
|
p2.execute(new ShortRunnable()); |
263 |
|
try { |
264 |
|
Thread.sleep(SMALL_DELAY_MS); |
265 |
< |
} catch (Exception e){ |
265 |
> |
} catch (Exception e) { |
266 |
|
unexpectedException(); |
267 |
|
} |
268 |
|
assertEquals(1, p2.getCompletedTaskCount()); |
375 |
|
p2.execute(new MediumRunnable()); |
376 |
|
Thread.sleep(SHORT_DELAY_MS); |
377 |
|
assertEquals(2, p2.getLargestPoolSize()); |
378 |
< |
} catch (Exception e){ |
378 |
> |
} catch (Exception e) { |
379 |
|
unexpectedException(); |
380 |
|
} |
381 |
|
joinPool(p2); |
413 |
|
p1.execute(new MediumRunnable()); |
414 |
|
Thread.sleep(SHORT_DELAY_MS); |
415 |
|
assertEquals(1, p1.getTaskCount()); |
416 |
< |
} catch (Exception e){ |
416 |
> |
} catch (Exception e) { |
417 |
|
unexpectedException(); |
418 |
|
} |
419 |
|
joinPool(p1); |
446 |
|
try { |
447 |
|
assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); |
448 |
|
assertTrue(p1.isTerminated()); |
449 |
< |
} catch (Exception e){ |
449 |
> |
} catch (Exception e) { |
450 |
|
unexpectedException(); |
451 |
|
} |
452 |
|
} |
467 |
|
assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); |
468 |
|
assertTrue(p1.isTerminated()); |
469 |
|
assertFalse(p1.isTerminating()); |
470 |
< |
} catch (Exception e){ |
470 |
> |
} catch (Exception e) { |
471 |
|
unexpectedException(); |
472 |
|
} |
473 |
|
} |
479 |
|
BlockingQueue<Runnable> q = new ArrayBlockingQueue<Runnable>(10); |
480 |
|
ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, q); |
481 |
|
FutureTask[] tasks = new FutureTask[5]; |
482 |
< |
for (int i = 0; i < 5; i++){ |
482 |
> |
for (int i = 0; i < 5; i++) { |
483 |
|
tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE); |
484 |
|
p1.execute(tasks[i]); |
485 |
|
} |
506 |
|
BlockingQueue<Runnable> q = new ArrayBlockingQueue<Runnable>(10); |
507 |
|
ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, q); |
508 |
|
FutureTask[] tasks = new FutureTask[5]; |
509 |
< |
for (int i = 0; i < 5; i++){ |
509 |
> |
for (int i = 0; i < 5; i++) { |
510 |
|
tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE); |
511 |
|
p1.execute(tasks[i]); |
512 |
|
} |
534 |
|
public void testPurge() { |
535 |
|
ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
536 |
|
FutureTask[] tasks = new FutureTask[5]; |
537 |
< |
for (int i = 0; i < 5; i++){ |
537 |
> |
for (int i = 0; i < 5; i++) { |
538 |
|
tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE); |
539 |
|
p1.execute(tasks[i]); |
540 |
|
} |
577 |
|
new CustomTPE(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
578 |
|
shouldThrow(); |
579 |
|
} |
580 |
< |
catch (IllegalArgumentException success){} |
580 |
> |
catch (IllegalArgumentException success) {} |
581 |
|
} |
582 |
|
|
583 |
|
/** |
588 |
|
new CustomTPE(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
589 |
|
shouldThrow(); |
590 |
|
} |
591 |
< |
catch (IllegalArgumentException success){} |
591 |
> |
catch (IllegalArgumentException success) {} |
592 |
|
} |
593 |
|
|
594 |
|
/** |
599 |
|
new CustomTPE(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
600 |
|
shouldThrow(); |
601 |
|
} |
602 |
< |
catch (IllegalArgumentException success){} |
602 |
> |
catch (IllegalArgumentException success) {} |
603 |
|
} |
604 |
|
|
605 |
|
/** |
610 |
|
new CustomTPE(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
611 |
|
shouldThrow(); |
612 |
|
} |
613 |
< |
catch (IllegalArgumentException success){} |
613 |
> |
catch (IllegalArgumentException success) {} |
614 |
|
} |
615 |
|
|
616 |
|
/** |
621 |
|
new CustomTPE(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
622 |
|
shouldThrow(); |
623 |
|
} |
624 |
< |
catch (IllegalArgumentException success){} |
624 |
> |
catch (IllegalArgumentException success) {} |
625 |
|
} |
626 |
|
|
627 |
|
/** |
632 |
|
new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null); |
633 |
|
shouldThrow(); |
634 |
|
} |
635 |
< |
catch (NullPointerException success){} |
635 |
> |
catch (NullPointerException success) {} |
636 |
|
} |
637 |
|
|
638 |
|
|
644 |
|
try { |
645 |
|
new CustomTPE(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory()); |
646 |
|
shouldThrow(); |
647 |
< |
} catch (IllegalArgumentException success){} |
647 |
> |
} catch (IllegalArgumentException success) {} |
648 |
|
} |
649 |
|
|
650 |
|
/** |
655 |
|
new CustomTPE(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory()); |
656 |
|
shouldThrow(); |
657 |
|
} |
658 |
< |
catch (IllegalArgumentException success){} |
658 |
> |
catch (IllegalArgumentException success) {} |
659 |
|
} |
660 |
|
|
661 |
|
/** |
666 |
|
new CustomTPE(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory()); |
667 |
|
shouldThrow(); |
668 |
|
} |
669 |
< |
catch (IllegalArgumentException success){} |
669 |
> |
catch (IllegalArgumentException success) {} |
670 |
|
} |
671 |
|
|
672 |
|
/** |
677 |
|
new CustomTPE(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory()); |
678 |
|
shouldThrow(); |
679 |
|
} |
680 |
< |
catch (IllegalArgumentException success){} |
680 |
> |
catch (IllegalArgumentException success) {} |
681 |
|
} |
682 |
|
|
683 |
|
/** |
688 |
|
new CustomTPE(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory()); |
689 |
|
shouldThrow(); |
690 |
|
} |
691 |
< |
catch (IllegalArgumentException success){} |
691 |
> |
catch (IllegalArgumentException success) {} |
692 |
|
} |
693 |
|
|
694 |
|
/** |
699 |
|
new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null,new SimpleThreadFactory()); |
700 |
|
shouldThrow(); |
701 |
|
} |
702 |
< |
catch (NullPointerException success){} |
702 |
> |
catch (NullPointerException success) {} |
703 |
|
} |
704 |
|
|
705 |
|
/** |
711 |
|
new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),f); |
712 |
|
shouldThrow(); |
713 |
|
} |
714 |
< |
catch (NullPointerException success){} |
714 |
> |
catch (NullPointerException success) {} |
715 |
|
} |
716 |
|
|
717 |
|
|
723 |
|
new CustomTPE(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler()); |
724 |
|
shouldThrow(); |
725 |
|
} |
726 |
< |
catch (IllegalArgumentException success){} |
726 |
> |
catch (IllegalArgumentException success) {} |
727 |
|
} |
728 |
|
|
729 |
|
/** |
734 |
|
new CustomTPE(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler()); |
735 |
|
shouldThrow(); |
736 |
|
} |
737 |
< |
catch (IllegalArgumentException success){} |
737 |
> |
catch (IllegalArgumentException success) {} |
738 |
|
} |
739 |
|
|
740 |
|
/** |
745 |
|
new CustomTPE(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler()); |
746 |
|
shouldThrow(); |
747 |
|
} |
748 |
< |
catch (IllegalArgumentException success){} |
748 |
> |
catch (IllegalArgumentException success) {} |
749 |
|
} |
750 |
|
|
751 |
|
/** |
756 |
|
new CustomTPE(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler()); |
757 |
|
shouldThrow(); |
758 |
|
} |
759 |
< |
catch (IllegalArgumentException success){} |
759 |
> |
catch (IllegalArgumentException success) {} |
760 |
|
} |
761 |
|
|
762 |
|
/** |
767 |
|
new CustomTPE(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler()); |
768 |
|
shouldThrow(); |
769 |
|
} |
770 |
< |
catch (IllegalArgumentException success){} |
770 |
> |
catch (IllegalArgumentException success) {} |
771 |
|
} |
772 |
|
|
773 |
|
/** |
778 |
|
new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null,new NoOpREHandler()); |
779 |
|
shouldThrow(); |
780 |
|
} |
781 |
< |
catch (NullPointerException success){} |
781 |
> |
catch (NullPointerException success) {} |
782 |
|
} |
783 |
|
|
784 |
|
/** |
790 |
|
new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),r); |
791 |
|
shouldThrow(); |
792 |
|
} |
793 |
< |
catch (NullPointerException success){} |
793 |
> |
catch (NullPointerException success) {} |
794 |
|
} |
795 |
|
|
796 |
|
|
802 |
|
new CustomTPE(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler()); |
803 |
|
shouldThrow(); |
804 |
|
} |
805 |
< |
catch (IllegalArgumentException success){} |
805 |
> |
catch (IllegalArgumentException success) {} |
806 |
|
} |
807 |
|
|
808 |
|
/** |
813 |
|
new CustomTPE(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler()); |
814 |
|
shouldThrow(); |
815 |
|
} |
816 |
< |
catch (IllegalArgumentException success){} |
816 |
> |
catch (IllegalArgumentException success) {} |
817 |
|
} |
818 |
|
|
819 |
|
/** |
824 |
|
new CustomTPE(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler()); |
825 |
|
shouldThrow(); |
826 |
|
} |
827 |
< |
catch (IllegalArgumentException success){} |
827 |
> |
catch (IllegalArgumentException success) {} |
828 |
|
} |
829 |
|
|
830 |
|
/** |
835 |
|
new CustomTPE(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler()); |
836 |
|
shouldThrow(); |
837 |
|
} |
838 |
< |
catch (IllegalArgumentException success){} |
838 |
> |
catch (IllegalArgumentException success) {} |
839 |
|
} |
840 |
|
|
841 |
|
/** |
846 |
|
new CustomTPE(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler()); |
847 |
|
shouldThrow(); |
848 |
|
} |
849 |
< |
catch (IllegalArgumentException success){} |
849 |
> |
catch (IllegalArgumentException success) {} |
850 |
|
} |
851 |
|
|
852 |
|
/** |
857 |
|
new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null,new SimpleThreadFactory(),new NoOpREHandler()); |
858 |
|
shouldThrow(); |
859 |
|
} |
860 |
< |
catch (NullPointerException success){} |
860 |
> |
catch (NullPointerException success) {} |
861 |
|
} |
862 |
|
|
863 |
|
/** |
869 |
|
new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),r); |
870 |
|
shouldThrow(); |
871 |
|
} |
872 |
< |
catch (NullPointerException success){} |
872 |
> |
catch (NullPointerException success) {} |
873 |
|
} |
874 |
|
|
875 |
|
/** |
881 |
|
new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),f,new NoOpREHandler()); |
882 |
|
shouldThrow(); |
883 |
|
} |
884 |
< |
catch (NullPointerException successdn8){} |
884 |
> |
catch (NullPointerException successdn8) {} |
885 |
|
} |
886 |
|
|
887 |
|
|
893 |
|
ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1)); |
894 |
|
try { |
895 |
|
|
896 |
< |
for (int i = 0; i < 5; ++i){ |
896 |
> |
for (int i = 0; i < 5; ++i) { |
897 |
|
p.execute(new MediumRunnable()); |
898 |
|
} |
899 |
|
shouldThrow(); |
900 |
< |
} catch (RejectedExecutionException success){} |
900 |
> |
} catch (RejectedExecutionException success) {} |
901 |
|
joinPool(p); |
902 |
|
} |
903 |
|
|
910 |
|
try { |
911 |
|
|
912 |
|
TrackedNoOpRunnable[] tasks = new TrackedNoOpRunnable[5]; |
913 |
< |
for (int i = 0; i < 5; ++i){ |
913 |
> |
for (int i = 0; i < 5; ++i) { |
914 |
|
tasks[i] = new TrackedNoOpRunnable(); |
915 |
|
} |
916 |
|
TrackedLongRunnable mr = new TrackedLongRunnable(); |
917 |
|
p.execute(mr); |
918 |
< |
for (int i = 0; i < 5; ++i){ |
918 |
> |
for (int i = 0; i < 5; ++i) { |
919 |
|
p.execute(tasks[i]); |
920 |
|
} |
921 |
|
for (int i = 1; i < 5; ++i) { |
922 |
|
assertTrue(tasks[i].done); |
923 |
|
} |
924 |
|
try { p.shutdownNow(); } catch (SecurityException ok) { return; } |
925 |
< |
} catch (RejectedExecutionException ex){ |
925 |
> |
} catch (RejectedExecutionException ex) { |
926 |
|
unexpectedException(); |
927 |
|
} finally { |
928 |
|
joinPool(p); |
938 |
|
try { |
939 |
|
|
940 |
|
TrackedNoOpRunnable[] tasks = new TrackedNoOpRunnable[5]; |
941 |
< |
for (int i = 0; i < 5; ++i){ |
941 |
> |
for (int i = 0; i < 5; ++i) { |
942 |
|
tasks[i] = new TrackedNoOpRunnable(); |
943 |
|
} |
944 |
|
p.execute(new TrackedLongRunnable()); |
945 |
< |
for (int i = 0; i < 5; ++i){ |
945 |
> |
for (int i = 0; i < 5; ++i) { |
946 |
|
p.execute(tasks[i]); |
947 |
|
} |
948 |
< |
for (int i = 0; i < 5; ++i){ |
948 |
> |
for (int i = 0; i < 5; ++i) { |
949 |
|
assertFalse(tasks[i].done); |
950 |
|
} |
951 |
|
try { p.shutdownNow(); } catch (SecurityException ok) { return; } |
952 |
< |
} catch (RejectedExecutionException ex){ |
952 |
> |
} catch (RejectedExecutionException ex) { |
953 |
|
unexpectedException(); |
954 |
|
} finally { |
955 |
|
joinPool(p); |
972 |
|
assertFalse(p.getQueue().contains(r2)); |
973 |
|
assertTrue(p.getQueue().contains(r3)); |
974 |
|
try { p.shutdownNow(); } catch (SecurityException ok) { return; } |
975 |
< |
} catch (RejectedExecutionException ex){ |
975 |
> |
} catch (RejectedExecutionException ex) { |
976 |
|
unexpectedException(); |
977 |
|
} finally { |
978 |
|
joinPool(p); |
989 |
|
try { |
990 |
|
tpe.execute(new NoOpRunnable()); |
991 |
|
shouldThrow(); |
992 |
< |
} catch (RejectedExecutionException success){} |
992 |
> |
} catch (RejectedExecutionException success) {} |
993 |
|
|
994 |
|
joinPool(tpe); |
995 |
|
} |
1006 |
|
TrackedNoOpRunnable r = new TrackedNoOpRunnable(); |
1007 |
|
p.execute(r); |
1008 |
|
assertFalse(r.done); |
1009 |
< |
} catch (RejectedExecutionException success){ |
1009 |
> |
} catch (RejectedExecutionException success) { |
1010 |
|
unexpectedException(); |
1011 |
|
} finally { |
1012 |
|
joinPool(p); |
1025 |
|
TrackedNoOpRunnable r = new TrackedNoOpRunnable(); |
1026 |
|
p.execute(r); |
1027 |
|
assertFalse(r.done); |
1028 |
< |
} catch (RejectedExecutionException success){ |
1028 |
> |
} catch (RejectedExecutionException success) { |
1029 |
|
unexpectedException(); |
1030 |
|
} finally { |
1031 |
|
joinPool(p); |
1045 |
|
TrackedNoOpRunnable r = new TrackedNoOpRunnable(); |
1046 |
|
p.execute(r); |
1047 |
|
assertFalse(r.done); |
1048 |
< |
} catch (RejectedExecutionException success){ |
1048 |
> |
} catch (RejectedExecutionException success) { |
1049 |
|
unexpectedException(); |
1050 |
|
} finally { |
1051 |
|
joinPool(p); |
1062 |
|
tpe = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10)); |
1063 |
|
tpe.execute(null); |
1064 |
|
shouldThrow(); |
1065 |
< |
} catch (NullPointerException success){} |
1065 |
> |
} catch (NullPointerException success) {} |
1066 |
|
|
1067 |
|
joinPool(tpe); |
1068 |
|
} |
1074 |
|
ThreadPoolExecutor tpe = null; |
1075 |
|
try { |
1076 |
|
tpe = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10)); |
1077 |
< |
} catch (Exception e){} |
1077 |
> |
} catch (Exception e) {} |
1078 |
|
try { |
1079 |
|
tpe.setCorePoolSize(-1); |
1080 |
|
shouldThrow(); |
1081 |
< |
} catch (IllegalArgumentException success){ |
1081 |
> |
} catch (IllegalArgumentException success) { |
1082 |
|
} finally { |
1083 |
|
try { tpe.shutdown(); } catch (SecurityException ok) { return; } |
1084 |
|
} |
1093 |
|
ThreadPoolExecutor tpe = null; |
1094 |
|
try { |
1095 |
|
tpe = new CustomTPE(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10)); |
1096 |
< |
} catch (Exception e){} |
1096 |
> |
} catch (Exception e) {} |
1097 |
|
try { |
1098 |
|
tpe.setMaximumPoolSize(1); |
1099 |
|
shouldThrow(); |
1100 |
< |
} catch (IllegalArgumentException success){ |
1100 |
> |
} catch (IllegalArgumentException success) { |
1101 |
|
} finally { |
1102 |
|
try { tpe.shutdown(); } catch (SecurityException ok) { return; } |
1103 |
|
} |
1112 |
|
ThreadPoolExecutor tpe = null; |
1113 |
|
try { |
1114 |
|
tpe = new CustomTPE(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10)); |
1115 |
< |
} catch (Exception e){} |
1115 |
> |
} catch (Exception e) {} |
1116 |
|
try { |
1117 |
|
tpe.setMaximumPoolSize(-1); |
1118 |
|
shouldThrow(); |
1119 |
< |
} catch (IllegalArgumentException success){ |
1119 |
> |
} catch (IllegalArgumentException success) { |
1120 |
|
} finally { |
1121 |
|
try { tpe.shutdown(); } catch (SecurityException ok) { return; } |
1122 |
|
} |
1132 |
|
ThreadPoolExecutor tpe = null; |
1133 |
|
try { |
1134 |
|
tpe = new CustomTPE(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10)); |
1135 |
< |
} catch (Exception e){} |
1135 |
> |
} catch (Exception e) {} |
1136 |
|
|
1137 |
|
try { |
1138 |
|
tpe.setKeepAliveTime(-1,TimeUnit.MILLISECONDS); |
1139 |
|
shouldThrow(); |
1140 |
< |
} catch (IllegalArgumentException success){ |
1140 |
> |
} catch (IllegalArgumentException success) { |
1141 |
|
} finally { |
1142 |
|
try { tpe.shutdown(); } catch (SecurityException ok) { return; } |
1143 |
|
} |
1688 |
|
try { |
1689 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
1690 |
|
assertEquals(0, tpe.getPoolSize()); |
1691 |
< |
} catch (InterruptedException e){ |
1691 |
> |
} catch (InterruptedException e) { |
1692 |
|
unexpectedException(); |
1693 |
|
} finally { |
1694 |
|
joinPool(tpe); |
1705 |
|
try { |
1706 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
1707 |
|
assertTrue(tpe.getPoolSize() >= 1); |
1708 |
< |
} catch (InterruptedException e){ |
1708 |
> |
} catch (InterruptedException e) { |
1709 |
|
unexpectedException(); |
1710 |
|
} finally { |
1711 |
|
joinPool(tpe); |