/*
* 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
/**
* RMI runtime implementation utilities.
*
* There is a single instance of this class, which can be obtained
* with a GetInstanceAction. Getting the instance requires
* RuntimePermission("sun.rmi.runtime.RuntimeUtil.getInstance")
* because the public methods of this class expose security-sensitive
* capabilities.
*
* @author Peter Jones
**/
public final class RuntimeUtil {
/** runtime package log */
/** number of scheduler threads */
/** permission required to get instance */
new RuntimePermission("sun.rmi.runtime.RuntimeUtil.getInstance");
/** the singleton instance of this class */
/** thread pool for scheduling delayed tasks */
private RuntimeUtil() {
new ThreadFactory() {
try {
return AccessController.doPrivileged(
new NewThreadAction(runnable,
true));
} catch (Throwable t) {
"scheduler thread factory throws", t);
return null;
}
}
});
/*
* We would like to allow the scheduler's threads to terminate
* if possible, but a bug in DelayQueue.poll can cause code
* like this to result in a busy loop:
*/
// stpe.setKeepAliveTime(10, TimeUnit.MINUTES);
// stpe.allowCoreThreadTimeOut(true);
}
/**
* A PrivilegedAction for getting the RuntimeUtil instance.
**/
public static class GetInstanceAction
implements PrivilegedAction<RuntimeUtil>
{
/**
* Creates an action that returns the RuntimeUtil instance.
**/
public GetInstanceAction() {
}
return getInstance();
}
}
}
return instance;
}
/**
* Returns the shared thread pool for scheduling delayed tasks.
*
* Note that the returned pool has limited concurrency, so
* submitted tasks should be short-lived and should not block.
**/
return scheduler;
}
}