/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6450200
* @summary Test proper handling of pool state changes
* @author Martin Buchholz
*/
public class ConfigChanges {
try {
"active=%d submitted=%d completed=%d queued=%d sizes=%d/%d/%d%n",
tg.activeCount(),
tpe.getTaskCount(),
tpe.getPoolSize(),
} catch (Throwable t) { unexpected(t); }
}
}
}
try {
if (new Random().nextBoolean()) {
if (es instanceof ThreadPoolExecutor)
|| es.isTerminated());
THROWS(RejectedExecutionException.class,
}
} catch (Throwable t) { unexpected(t); }
}
try {
} catch (Throwable t) { unexpected(t); }
}
catch (Throwable t) { unexpected(t); }}};
}
if (rnd.nextBoolean())
= new Thread.UncaughtExceptionHandler() {
unexpected(e);
}};
final int n = 3;
final ThreadPoolExecutor tpe
= new ThreadPoolExecutor(n, 3*n,
3L, MINUTES,
return t;
}});
if (prestart) {
}
final Runnable runRunnableDuJour =
// Delay choice of action till last possible moment.
runnableDuJour.run(); }};
if (prestart) {
for (int i = 0; i < 1*n; i++)
// Wait for prestarted threads to dequeue their initial tasks.
for (int i = 0; i < 5*n; i++)
} else {
for (int i = 0; i < 6*n; i++)
}
//report("submitted", tpe);
//report("pumped up", tpe);
//report("pumped up2", tpe);
for (int i = 0; i < 1*n; i++)
//report("pumped up2", tpe);
//report("after set", tpe);
// while (tg.activeCount() != n &&
// tg.activeCount() != n)
// Thread.sleep(10);
// equal(tg.activeCount(), n);
// equal(tg.activeCount(), tpe.getCorePoolSize());
//report("draining", tpe);
//equal(tg.activeCount(), n);
//equal(tg.activeCount(), tpe.getCorePoolSize());
while (tg.activeCount() > n &&
tg.activeCount() > n)
//report("idle", tpe);
tpe.allowCoreThreadTimeOut(true);
//report("idle", tpe);
}
//--------------------- Infrastructure ---------------------------
else fail(x + " not equal to " + y);}
catch (Throwable t) {
else unexpected(t);}}
}