1/* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17package libcore.java.util.concurrent; 18 19import junit.framework.TestCase; 20 21import java.util.concurrent.ArrayBlockingQueue; 22import java.util.concurrent.ThreadPoolExecutor; 23import java.util.concurrent.TimeUnit; 24 25public class ThreadPoolExecutorTest extends TestCase { 26 27 // http://b/27702221 28 public void testCorePoolSizeGreaterThanMax() { 29 ThreadPoolExecutor tp = new ThreadPoolExecutor( 30 1 /* core pool size */, 1 /* max pool size */, 31 1000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(10)); 32 33 // It should be illegal to set a core pool size that's larger than the max 34 // pool size but apps have been allowed to get away with it so far. The pattern 35 // below occurs in a commonly used library. Note that the executor is in a sane 36 // state at the end of both method calls. 37 tp.setCorePoolSize(5); 38 tp.setMaximumPoolSize(5); 39 } 40} 41