134N/A/*
2362N/A * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
134N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
134N/A *
134N/A * This code is free software; you can redistribute it and/or modify it
134N/A * under the terms of the GNU General Public License version 2 only, as
134N/A * published by the Free Software Foundation.
134N/A *
134N/A * This code is distributed in the hope that it will be useful, but WITHOUT
134N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
134N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
134N/A * version 2 for more details (a copy is included in the LICENSE file that
134N/A * accompanied this code).
134N/A *
134N/A * You should have received a copy of the GNU General Public License version
134N/A * 2 along with this work; if not, write to the Free Software Foundation,
134N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
134N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
134N/A */
134N/A
134N/A/* @test
134N/A * @bug 4531740
134N/A * @summary Checks that wakeup works for an empty Selector
134N/A * @author kladko
134N/A */
134N/A
134N/Aimport java.nio.*;
134N/Aimport java.nio.channels.*;
134N/A
134N/Apublic class WakeupEmpty {
134N/A
134N/A private final static int SLEEP_TIME = 100;
134N/A
134N/A public static void main(String[] argv) throws Exception {
134N/A final Selector sel = Selector.open();
134N/A Thread thread = new Thread() {
134N/A public void run() {
134N/A try {
134N/A sleep(SLEEP_TIME);
134N/A } catch (InterruptedException e) {
134N/A //ignore
134N/A }
134N/A sel.wakeup();
134N/A }
134N/A };
134N/A thread.start();
134N/A if (sel.select() != 0)
134N/A throw new Exception("Zero expected");
134N/A }
134N/A}
134N/A