blob: a7fe06a43b06e13d57672177530e8f4906f7521b [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0-google-internal) on Mon Jan 04 20:48:00 PST 2010 -->
<TITLE>
Executors (Guava Libraries 2010.01.04)
</TITLE>
<META NAME="date" CONTENT="2010-01-04">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Executors (Guava Libraries 2010.01.04)";
}
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<HR>
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Executors.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../../com/google/common/util/concurrent/ExecutionList.html" title="class in com.google.common.util.concurrent"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../../com/google/common/util/concurrent/FakeTimeLimiter.html" title="class in com.google.common.util.concurrent"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../index.html?com/google/common/util/concurrent/Executors.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="Executors.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
com.google.common.util.concurrent</FONT>
<BR>
Class Executors</H2>
<PRE>
<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</A>
<IMG SRC="../../../../../resources/inherit.gif" ALT="extended by "><B>com.google.common.util.concurrent.Executors</B>
</PRE>
<HR>
<DL>
<DT><PRE>public class <B>Executors</B><DT>extends <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></DL>
</PRE>
<P>
Factory and utility methods for <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/Executor.html?is-external=true" title="class or interface in java.util.concurrent"><CODE>Executor</CODE></A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ExecutorService.html?is-external=true" title="class or interface in java.util.concurrent"><CODE>ExecutorService</CODE></A>, and <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadFactory.html?is-external=true" title="class or interface in java.util.concurrent"><CODE>ThreadFactory</CODE></A>.
<P>
<P>
<DL>
<DT><B>Since:</B></DT>
<DD>2009.09.15 <b>tentative</b></DD>
<DT><B>Author:</B></DT>
<DD>Eric Fellheimer, Kyle Littlefield, Justin Mahoney</DD>
</DL>
<HR>
<P>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../../../com/google/common/util/concurrent/Executors.html#Executors()">Executors</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
</TABLE>
&nbsp;
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/common/util/concurrent/Executors.html#addDelayedShutdownHook(java.util.concurrent.ExecutorService, long, java.util.concurrent.TimeUnit)">addDelayedShutdownHook</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ExecutorService</A>&nbsp;service,
long&nbsp;terminationTimeout,
<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/TimeUnit.html?is-external=true" title="class or interface in java.util.concurrent">TimeUnit</A>&nbsp;timeUnit)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Add a shutdown hook to wait for thread completion in the given
<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ExecutorService.html?is-external=true" title="class or interface in java.util.concurrent"><CODE>service</CODE></A>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadFactory.html?is-external=true" title="class or interface in java.util.concurrent">ThreadFactory</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/common/util/concurrent/Executors.html#daemonThreadFactory()">daemonThreadFactory</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadFactory.html?is-external=true" title="class or interface in java.util.concurrent"><CODE>ThreadFactory</CODE></A> which creates daemon threads.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadFactory.html?is-external=true" title="class or interface in java.util.concurrent">ThreadFactory</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/common/util/concurrent/Executors.html#daemonThreadFactory(java.util.concurrent.ThreadFactory)">daemonThreadFactory</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadFactory.html?is-external=true" title="class or interface in java.util.concurrent">ThreadFactory</A>&nbsp;factory)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Wraps another <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadFactory.html?is-external=true" title="class or interface in java.util.concurrent"><CODE>ThreadFactory</CODE></A>, making all new threads daemon threads.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ExecutorService</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/common/util/concurrent/Executors.html#getExitingExecutorService(java.util.concurrent.ThreadPoolExecutor)">getExitingExecutorService</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html?is-external=true" title="class or interface in java.util.concurrent">ThreadPoolExecutor</A>&nbsp;executor)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Converts the given ThreadPoolExecutor into an ExecutorService that exits
when the application is complete.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ExecutorService</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/common/util/concurrent/Executors.html#getExitingExecutorService(java.util.concurrent.ThreadPoolExecutor, long, java.util.concurrent.TimeUnit)">getExitingExecutorService</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html?is-external=true" title="class or interface in java.util.concurrent">ThreadPoolExecutor</A>&nbsp;executor,
long&nbsp;terminationTimeout,
<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/TimeUnit.html?is-external=true" title="class or interface in java.util.concurrent">TimeUnit</A>&nbsp;timeUnit)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Converts the given ThreadPoolExecutor into an ExecutorService that exits
when the application is complete.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ScheduledExecutorService</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/common/util/concurrent/Executors.html#getExitingScheduledExecutorService(java.util.concurrent.ScheduledThreadPoolExecutor)">getExitingScheduledExecutorService</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html?is-external=true" title="class or interface in java.util.concurrent">ScheduledThreadPoolExecutor</A>&nbsp;executor)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Converts the given ThreadPoolExecutor into a ScheduledExecutorService that
exits when the application is complete.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ScheduledExecutorService</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/common/util/concurrent/Executors.html#getExitingScheduledExecutorService(java.util.concurrent.ScheduledThreadPoolExecutor, long, java.util.concurrent.TimeUnit)">getExitingScheduledExecutorService</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html?is-external=true" title="class or interface in java.util.concurrent">ScheduledThreadPoolExecutor</A>&nbsp;executor,
long&nbsp;terminationTimeout,
<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/TimeUnit.html?is-external=true" title="class or interface in java.util.concurrent">TimeUnit</A>&nbsp;timeUnit)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Converts the given ScheduledThreadPoolExecutor into a
ScheduledExecutorService that exits when the application is complete.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ExecutorService</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/common/util/concurrent/Executors.html#sameThreadExecutor()">sameThreadExecutor</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Creates an executor service that runs each task in the thread
that invokes <code>execute/submit</code>, as in <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.CallerRunsPolicy.html?is-external=true" title="class or interface in java.util.concurrent"><CODE>ThreadPoolExecutor.CallerRunsPolicy</CODE></A> This
applies both to individually submitted tasks and to collections of tasks
submitted via <code>invokeAll</code> or <code>invokeAny</code>.</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Methods inherited from class java.lang.<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD>
</TR>
</TABLE>
&nbsp;
<P>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="Executors()"><!-- --></A><H3>
Executors</H3>
<PRE>
public <B>Executors</B>()</PRE>
<DL>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="getExitingExecutorService(java.util.concurrent.ThreadPoolExecutor, long, java.util.concurrent.TimeUnit)"><!-- --></A><H3>
getExitingExecutorService</H3>
<PRE>
public static <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ExecutorService</A> <B>getExitingExecutorService</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html?is-external=true" title="class or interface in java.util.concurrent">ThreadPoolExecutor</A>&nbsp;executor,
long&nbsp;terminationTimeout,
<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/TimeUnit.html?is-external=true" title="class or interface in java.util.concurrent">TimeUnit</A>&nbsp;timeUnit)</PRE>
<DL>
<DD>Converts the given ThreadPoolExecutor into an ExecutorService that exits
when the application is complete. It does so by using daemon threads and
adding a shutdown hook to wait for their completion.
<p>This is mainly for fixed thread pools.
See <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/Executors.html?is-external=true#newFixedThreadPool(int)" title="class or interface in java.util.concurrent"><CODE>Executors.newFixedThreadPool(int)</CODE></A>.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>executor</CODE> - the executor to modify to make sure it exits when the
application is finished<DD><CODE>terminationTimeout</CODE> - how long to wait for the executor to
finish before terminating the JVM<DD><CODE>timeUnit</CODE> - unit of time for the time parameter
<DT><B>Returns:</B><DD>an unmodifiable version of the input which will not hang the JVM</DL>
</DD>
</DL>
<HR>
<A NAME="getExitingScheduledExecutorService(java.util.concurrent.ScheduledThreadPoolExecutor, long, java.util.concurrent.TimeUnit)"><!-- --></A><H3>
getExitingScheduledExecutorService</H3>
<PRE>
public static <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ScheduledExecutorService</A> <B>getExitingScheduledExecutorService</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html?is-external=true" title="class or interface in java.util.concurrent">ScheduledThreadPoolExecutor</A>&nbsp;executor,
long&nbsp;terminationTimeout,
<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/TimeUnit.html?is-external=true" title="class or interface in java.util.concurrent">TimeUnit</A>&nbsp;timeUnit)</PRE>
<DL>
<DD>Converts the given ScheduledThreadPoolExecutor into a
ScheduledExecutorService that exits when the application is complete. It
does so by using daemon threads and adding a shutdown hook to wait for
their completion.
<p>This is mainly for fixed thread pools.
See <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/Executors.html?is-external=true#newScheduledThreadPool(int)" title="class or interface in java.util.concurrent"><CODE>Executors.newScheduledThreadPool(int)</CODE></A>.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>executor</CODE> - the executor to modify to make sure it exits when the
application is finished<DD><CODE>terminationTimeout</CODE> - how long to wait for the executor to
finish before terminating the JVM<DD><CODE>timeUnit</CODE> - unit of time for the time parameter
<DT><B>Returns:</B><DD>an unmodifiable version of the input which will not hang the JVM</DL>
</DD>
</DL>
<HR>
<A NAME="addDelayedShutdownHook(java.util.concurrent.ExecutorService, long, java.util.concurrent.TimeUnit)"><!-- --></A><H3>
addDelayedShutdownHook</H3>
<PRE>
public static void <B>addDelayedShutdownHook</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ExecutorService</A>&nbsp;service,
long&nbsp;terminationTimeout,
<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/TimeUnit.html?is-external=true" title="class or interface in java.util.concurrent">TimeUnit</A>&nbsp;timeUnit)</PRE>
<DL>
<DD>Add a shutdown hook to wait for thread completion in the given
<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ExecutorService.html?is-external=true" title="class or interface in java.util.concurrent"><CODE>service</CODE></A>. This is useful if the given service uses
daemon threads, and we want to keep the JVM from exiting immediately on
shutdown, instead giving these daemon threads a chance to terminate
normally.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>service</CODE> - ExecutorService which uses daemon threads<DD><CODE>terminationTimeout</CODE> - how long to wait for the executor to finish
before terminating the JVM<DD><CODE>timeUnit</CODE> - unit of time for the time parameter</DL>
</DD>
</DL>
<HR>
<A NAME="getExitingExecutorService(java.util.concurrent.ThreadPoolExecutor)"><!-- --></A><H3>
getExitingExecutorService</H3>
<PRE>
public static <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ExecutorService</A> <B>getExitingExecutorService</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html?is-external=true" title="class or interface in java.util.concurrent">ThreadPoolExecutor</A>&nbsp;executor)</PRE>
<DL>
<DD>Converts the given ThreadPoolExecutor into an ExecutorService that exits
when the application is complete. It does so by using daemon threads and
adding a shutdown hook to wait for their completion.
<p>This method waits 120 seconds before continuing with JVM termination,
even if the executor has not finished its work.
<p>This is mainly for fixed thread pools.
See <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/Executors.html?is-external=true#newFixedThreadPool(int)" title="class or interface in java.util.concurrent"><CODE>Executors.newFixedThreadPool(int)</CODE></A>.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>executor</CODE> - the executor to modify to make sure it exits when the
application is finished
<DT><B>Returns:</B><DD>an unmodifiable version of the input which will not hang the JVM</DL>
</DD>
</DL>
<HR>
<A NAME="getExitingScheduledExecutorService(java.util.concurrent.ScheduledThreadPoolExecutor)"><!-- --></A><H3>
getExitingScheduledExecutorService</H3>
<PRE>
public static <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ScheduledExecutorService</A> <B>getExitingScheduledExecutorService</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html?is-external=true" title="class or interface in java.util.concurrent">ScheduledThreadPoolExecutor</A>&nbsp;executor)</PRE>
<DL>
<DD>Converts the given ThreadPoolExecutor into a ScheduledExecutorService that
exits when the application is complete. It does so by using daemon threads
and adding a shutdown hook to wait for their completion.
<p>This method waits 120 seconds before continuing with JVM termination,
even if the executor has not finished its work.
<p>This is mainly for fixed thread pools.
See <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/Executors.html?is-external=true#newScheduledThreadPool(int)" title="class or interface in java.util.concurrent"><CODE>Executors.newScheduledThreadPool(int)</CODE></A>.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>executor</CODE> - the executor to modify to make sure it exits when the
application is finished
<DT><B>Returns:</B><DD>an unmodifiable version of the input which will not hang the JVM</DL>
</DD>
</DL>
<HR>
<A NAME="daemonThreadFactory()"><!-- --></A><H3>
daemonThreadFactory</H3>
<PRE>
public static <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadFactory.html?is-external=true" title="class or interface in java.util.concurrent">ThreadFactory</A> <B>daemonThreadFactory</B>()</PRE>
<DL>
<DD>Returns a <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadFactory.html?is-external=true" title="class or interface in java.util.concurrent"><CODE>ThreadFactory</CODE></A> which creates daemon threads. This is
implemented by wrapping <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/Executors.html?is-external=true#defaultThreadFactory()" title="class or interface in java.util.concurrent"><CODE>Executors.defaultThreadFactory()</CODE></A>, marking all new
threads as daemon threads
<P>
<DD><DL>
<DT><B>Returns:</B><DD>a <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadFactory.html?is-external=true" title="class or interface in java.util.concurrent"><CODE>ThreadFactory</CODE></A> which creates daemon threads</DL>
</DD>
</DL>
<HR>
<A NAME="daemonThreadFactory(java.util.concurrent.ThreadFactory)"><!-- --></A><H3>
daemonThreadFactory</H3>
<PRE>
public static <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadFactory.html?is-external=true" title="class or interface in java.util.concurrent">ThreadFactory</A> <B>daemonThreadFactory</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadFactory.html?is-external=true" title="class or interface in java.util.concurrent">ThreadFactory</A>&nbsp;factory)</PRE>
<DL>
<DD>Wraps another <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadFactory.html?is-external=true" title="class or interface in java.util.concurrent"><CODE>ThreadFactory</CODE></A>, making all new threads daemon threads.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>factory</CODE> - the <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadFactory.html?is-external=true" title="class or interface in java.util.concurrent"><CODE>ThreadFactory</CODE></A> used to generate new threads
<DT><B>Returns:</B><DD>a new <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadFactory.html?is-external=true" title="class or interface in java.util.concurrent"><CODE>ThreadFactory</CODE></A> backed by <code>factory</code> whose created
threads are all daemon threads</DL>
</DD>
</DL>
<HR>
<A NAME="sameThreadExecutor()"><!-- --></A><H3>
sameThreadExecutor</H3>
<PRE>
public static <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ExecutorService</A> <B>sameThreadExecutor</B>()</PRE>
<DL>
<DD>Creates an executor service that runs each task in the thread
that invokes <code>execute/submit</code>, as in <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.CallerRunsPolicy.html?is-external=true" title="class or interface in java.util.concurrent"><CODE>ThreadPoolExecutor.CallerRunsPolicy</CODE></A> This
applies both to individually submitted tasks and to collections of tasks
submitted via <code>invokeAll</code> or <code>invokeAny</code>. In the latter case,
tasks will run serially on the calling thread. Tasks are run to
completion before a <code>Future</code> is returned to the caller (unless the
executor has been shutdown).
<p>Although all tasks are immediately executed in the thread that
submitted the task, this <code>ExecutorService</code> imposes a small
locking overhead on each task submission in order to implement shutdown
and termination behavior.
<p>The implementation deviates from the <code>ExecutorService</code>
specification with regards to the <code>shutdownNow</code> method. First,
"best-effort" with regards to canceling running tasks is implemented
as "no-effort". No interrupts or other attempts are made to stop
threads executing tasks. Second, the returned list will always be empty,
as any submitted task is considered to have started execution.
This applies also to tasks given to <code>invokeAll</code> or <code>invokeAny</code>
which are pending serial execution, even the subset of the tasks that
have not yet started execution. It is unclear from the
<code>ExecutorService</code> specification if these should be included, and
it's much easier to implement the interpretation that they not be.
Finally, a call to <code>shutdown</code> or <code>shutdownNow</code> may result
in concurrent calls to <code>invokeAll/invokeAny</code> throwing
RejectedExecutionException, although a subset of the tasks may already
have been executed.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Executors.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../../com/google/common/util/concurrent/ExecutionList.html" title="class in com.google.common.util.concurrent"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../../com/google/common/util/concurrent/FakeTimeLimiter.html" title="class in com.google.common.util.concurrent"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../index.html?com/google/common/util/concurrent/Executors.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="Executors.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<HR>
</BODY>
</HTML>