• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<!--NewPage-->
3<HTML>
4<HEAD>
5<!-- Generated by javadoc (build 1.6.0-google-internal) on Mon Jan 04 20:48:00 PST 2010 -->
6<TITLE>
7Executors (Guava Libraries 2010.01.04)
8</TITLE>
9
10<META NAME="date" CONTENT="2010-01-04">
11
12<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style">
13
14<SCRIPT type="text/javascript">
15function windowTitle()
16{
17    if (location.href.indexOf('is-external=true') == -1) {
18        parent.document.title="Executors (Guava Libraries 2010.01.04)";
19    }
20}
21</SCRIPT>
22<NOSCRIPT>
23</NOSCRIPT>
24
25</HEAD>
26
27<BODY BGCOLOR="white" onload="windowTitle();">
28<HR>
29
30
31<!-- ========= START OF TOP NAVBAR ======= -->
32<A NAME="navbar_top"><!-- --></A>
33<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
34<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
35<TR>
36<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
37<A NAME="navbar_top_firstrow"><!-- --></A>
38<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
39  <TR ALIGN="center" VALIGN="top">
40  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
41  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
42  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
43  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/Executors.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
44  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
45  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
46  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
47  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
48  </TR>
49</TABLE>
50</TD>
51<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
52</EM>
53</TD>
54</TR>
55
56<TR>
57<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
58&nbsp;<A HREF="../../../../../com/google/common/util/concurrent/ExecutionList.html" title="class in com.google.common.util.concurrent"><B>PREV CLASS</B></A>&nbsp;
59&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>
60<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
61  <A HREF="../../../../../index.html?com/google/common/util/concurrent/Executors.html" target="_top"><B>FRAMES</B></A>  &nbsp;
62&nbsp;<A HREF="Executors.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
63&nbsp;<SCRIPT type="text/javascript">
64  <!--
65  if(window==top) {
66    document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
67  }
68  //-->
69</SCRIPT>
70<NOSCRIPT>
71  <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
72</NOSCRIPT>
73
74
75</FONT></TD>
76</TR>
77<TR>
78<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
79  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
80<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
81DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
82</TR>
83</TABLE>
84<A NAME="skip-navbar_top"></A>
85<!-- ========= END OF TOP NAVBAR ========= -->
86
87<HR>
88<!-- ======== START OF CLASS DATA ======== -->
89<H2>
90<FONT SIZE="-1">
91com.google.common.util.concurrent</FONT>
92<BR>
93Class Executors</H2>
94<PRE>
95<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>
96  <IMG SRC="../../../../../resources/inherit.gif" ALT="extended by "><B>com.google.common.util.concurrent.Executors</B>
97</PRE>
98<HR>
99<DL>
100<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>
101</PRE>
102
103<P>
104Factory 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>.
105<P>
106
107<P>
108<DL>
109<DT><B>Since:</B></DT>
110  <DD>2009.09.15 <b>tentative</b></DD>
111<DT><B>Author:</B></DT>
112  <DD>Eric Fellheimer, Kyle Littlefield, Justin Mahoney</DD>
113</DL>
114<HR>
115
116<P>
117
118<!-- ======== CONSTRUCTOR SUMMARY ======== -->
119
120<A NAME="constructor_summary"><!-- --></A>
121<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
122<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
123<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
124<B>Constructor Summary</B></FONT></TH>
125</TR>
126<TR BGCOLOR="white" CLASS="TableRowColor">
127<TD><CODE><B><A HREF="../../../../../com/google/common/util/concurrent/Executors.html#Executors()">Executors</A></B>()</CODE>
128
129<BR>
130&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
131</TR>
132</TABLE>
133&nbsp;
134<!-- ========== METHOD SUMMARY =========== -->
135
136<A NAME="method_summary"><!-- --></A>
137<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
138<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
139<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
140<B>Method Summary</B></FONT></TH>
141</TR>
142<TR BGCOLOR="white" CLASS="TableRowColor">
143<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
144<CODE>static&nbsp;void</CODE></FONT></TD>
145<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,
146                       long&nbsp;terminationTimeout,
147                       <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>
148
149<BR>
150&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Add a shutdown hook to wait for thread completion in the given
151 <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>
152</TR>
153<TR BGCOLOR="white" CLASS="TableRowColor">
154<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
155<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>
156<TD><CODE><B><A HREF="../../../../../com/google/common/util/concurrent/Executors.html#daemonThreadFactory()">daemonThreadFactory</A></B>()</CODE>
157
158<BR>
159&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>
160</TR>
161<TR BGCOLOR="white" CLASS="TableRowColor">
162<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
163<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>
164<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>
165
166<BR>
167&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>
168</TR>
169<TR BGCOLOR="white" CLASS="TableRowColor">
170<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
171<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>
172<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>
173
174<BR>
175&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Converts the given ThreadPoolExecutor into an ExecutorService that exits
176 when the application is complete.</TD>
177</TR>
178<TR BGCOLOR="white" CLASS="TableRowColor">
179<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
180<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>
181<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,
182                          long&nbsp;terminationTimeout,
183                          <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>
184
185<BR>
186&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Converts the given ThreadPoolExecutor into an ExecutorService that exits
187 when the application is complete.</TD>
188</TR>
189<TR BGCOLOR="white" CLASS="TableRowColor">
190<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
191<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>
192<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>
193
194<BR>
195&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Converts the given ThreadPoolExecutor into a ScheduledExecutorService that
196 exits when the application is complete.</TD>
197</TR>
198<TR BGCOLOR="white" CLASS="TableRowColor">
199<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
200<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>
201<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,
202                                   long&nbsp;terminationTimeout,
203                                   <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>
204
205<BR>
206&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Converts the given ScheduledThreadPoolExecutor into a
207 ScheduledExecutorService that exits when the application is complete.</TD>
208</TR>
209<TR BGCOLOR="white" CLASS="TableRowColor">
210<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
211<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>
212<TD><CODE><B><A HREF="../../../../../com/google/common/util/concurrent/Executors.html#sameThreadExecutor()">sameThreadExecutor</A></B>()</CODE>
213
214<BR>
215&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Creates an executor service that runs each task in the thread
216 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
217 applies both to individually submitted tasks and to collections of tasks
218 submitted via <code>invokeAll</code> or <code>invokeAny</code>.</TD>
219</TR>
220</TABLE>
221&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
222<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
223<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
224<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>
225</TR>
226<TR BGCOLOR="white" CLASS="TableRowColor">
227<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>
228</TR>
229</TABLE>
230&nbsp;
231<P>
232
233<!-- ========= CONSTRUCTOR DETAIL ======== -->
234
235<A NAME="constructor_detail"><!-- --></A>
236<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
237<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
238<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
239<B>Constructor Detail</B></FONT></TH>
240</TR>
241</TABLE>
242
243<A NAME="Executors()"><!-- --></A><H3>
244Executors</H3>
245<PRE>
246public <B>Executors</B>()</PRE>
247<DL>
248</DL>
249
250<!-- ============ METHOD DETAIL ========== -->
251
252<A NAME="method_detail"><!-- --></A>
253<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
254<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
255<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
256<B>Method Detail</B></FONT></TH>
257</TR>
258</TABLE>
259
260<A NAME="getExitingExecutorService(java.util.concurrent.ThreadPoolExecutor, long, java.util.concurrent.TimeUnit)"><!-- --></A><H3>
261getExitingExecutorService</H3>
262<PRE>
263public 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,
264                                                        long&nbsp;terminationTimeout,
265                                                        <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>
266<DL>
267<DD>Converts the given ThreadPoolExecutor into an ExecutorService that exits
268 when the application is complete.  It does so by using daemon threads and
269 adding a shutdown hook to wait for their completion.
270
271 <p>This is mainly for fixed thread pools.
272 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>.
273<P>
274<DD><DL>
275<DT><B>Parameters:</B><DD><CODE>executor</CODE> - the executor to modify to make sure it exits when the
276        application is finished<DD><CODE>terminationTimeout</CODE> - how long to wait for the executor to
277        finish before terminating the JVM<DD><CODE>timeUnit</CODE> - unit of time for the time parameter
278<DT><B>Returns:</B><DD>an unmodifiable version of the input which will not hang the JVM</DL>
279</DD>
280</DL>
281<HR>
282
283<A NAME="getExitingScheduledExecutorService(java.util.concurrent.ScheduledThreadPoolExecutor, long, java.util.concurrent.TimeUnit)"><!-- --></A><H3>
284getExitingScheduledExecutorService</H3>
285<PRE>
286public 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,
287                                                                          long&nbsp;terminationTimeout,
288                                                                          <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>
289<DL>
290<DD>Converts the given ScheduledThreadPoolExecutor into a
291 ScheduledExecutorService that exits when the application is complete.  It
292 does so by using daemon threads and adding a shutdown hook to wait for
293 their completion.
294
295 <p>This is mainly for fixed thread pools.
296 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>.
297<P>
298<DD><DL>
299<DT><B>Parameters:</B><DD><CODE>executor</CODE> - the executor to modify to make sure it exits when the
300        application is finished<DD><CODE>terminationTimeout</CODE> - how long to wait for the executor to
301        finish before terminating the JVM<DD><CODE>timeUnit</CODE> - unit of time for the time parameter
302<DT><B>Returns:</B><DD>an unmodifiable version of the input which will not hang the JVM</DL>
303</DD>
304</DL>
305<HR>
306
307<A NAME="addDelayedShutdownHook(java.util.concurrent.ExecutorService, long, java.util.concurrent.TimeUnit)"><!-- --></A><H3>
308addDelayedShutdownHook</H3>
309<PRE>
310public 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,
311                                          long&nbsp;terminationTimeout,
312                                          <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>
313<DL>
314<DD>Add a shutdown hook to wait for thread completion in the given
315 <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
316 daemon threads, and we want to keep the JVM from exiting immediately on
317 shutdown, instead giving these daemon threads a chance to terminate
318 normally.
319<P>
320<DD><DL>
321<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
322        before terminating the JVM<DD><CODE>timeUnit</CODE> - unit of time for the time parameter</DL>
323</DD>
324</DL>
325<HR>
326
327<A NAME="getExitingExecutorService(java.util.concurrent.ThreadPoolExecutor)"><!-- --></A><H3>
328getExitingExecutorService</H3>
329<PRE>
330public 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>
331<DL>
332<DD>Converts the given ThreadPoolExecutor into an ExecutorService that exits
333 when the application is complete.  It does so by using daemon threads and
334 adding a shutdown hook to wait for their completion.
335
336 <p>This method waits 120 seconds before continuing with JVM termination,
337 even if the executor has not finished its work.
338
339 <p>This is mainly for fixed thread pools.
340 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>.
341<P>
342<DD><DL>
343<DT><B>Parameters:</B><DD><CODE>executor</CODE> - the executor to modify to make sure it exits when the
344        application is finished
345<DT><B>Returns:</B><DD>an unmodifiable version of the input which will not hang the JVM</DL>
346</DD>
347</DL>
348<HR>
349
350<A NAME="getExitingScheduledExecutorService(java.util.concurrent.ScheduledThreadPoolExecutor)"><!-- --></A><H3>
351getExitingScheduledExecutorService</H3>
352<PRE>
353public 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>
354<DL>
355<DD>Converts the given ThreadPoolExecutor into a ScheduledExecutorService that
356 exits when the application is complete.  It does so by using daemon threads
357 and adding a shutdown hook to wait for their completion.
358
359 <p>This method waits 120 seconds before continuing with JVM termination,
360 even if the executor has not finished its work.
361
362 <p>This is mainly for fixed thread pools.
363 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>.
364<P>
365<DD><DL>
366<DT><B>Parameters:</B><DD><CODE>executor</CODE> - the executor to modify to make sure it exits when the
367        application is finished
368<DT><B>Returns:</B><DD>an unmodifiable version of the input which will not hang the JVM</DL>
369</DD>
370</DL>
371<HR>
372
373<A NAME="daemonThreadFactory()"><!-- --></A><H3>
374daemonThreadFactory</H3>
375<PRE>
376public 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>
377<DL>
378<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
379 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
380 threads as daemon threads
381<P>
382<DD><DL>
383
384<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>
385</DD>
386</DL>
387<HR>
388
389<A NAME="daemonThreadFactory(java.util.concurrent.ThreadFactory)"><!-- --></A><H3>
390daemonThreadFactory</H3>
391<PRE>
392public 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>
393<DL>
394<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.
395<P>
396<DD><DL>
397<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
398<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
399         threads are all daemon threads</DL>
400</DD>
401</DL>
402<HR>
403
404<A NAME="sameThreadExecutor()"><!-- --></A><H3>
405sameThreadExecutor</H3>
406<PRE>
407public 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>
408<DL>
409<DD>Creates an executor service that runs each task in the thread
410 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
411 applies both to individually submitted tasks and to collections of tasks
412 submitted via <code>invokeAll</code> or <code>invokeAny</code>.  In the latter case,
413 tasks will run serially on the calling thread.  Tasks are run to
414 completion before a <code>Future</code> is returned to the caller (unless the
415 executor has been shutdown).
416
417 <p>Although all tasks are immediately executed in the thread that
418 submitted the task, this <code>ExecutorService</code> imposes a small
419 locking overhead on each task submission in order to implement shutdown
420 and termination behavior.
421
422 <p>The implementation deviates from the <code>ExecutorService</code>
423 specification with regards to the <code>shutdownNow</code> method.  First,
424 "best-effort" with regards to canceling running tasks is implemented
425 as "no-effort".  No interrupts or other attempts are made to stop
426 threads executing tasks.  Second, the returned list will always be empty,
427 as any submitted task is considered to have started execution.
428 This applies also to tasks given to <code>invokeAll</code> or <code>invokeAny</code>
429 which are pending serial execution, even the subset of the tasks that
430 have not yet started execution.  It is unclear from the
431 <code>ExecutorService</code> specification if these should be included, and
432 it's much easier to implement the interpretation that they not be.
433 Finally, a call to <code>shutdown</code> or <code>shutdownNow</code> may result
434 in concurrent calls to <code>invokeAll/invokeAny</code> throwing
435 RejectedExecutionException, although a subset of the tasks may already
436 have been executed.
437<P>
438<DD><DL>
439</DL>
440</DD>
441</DL>
442<!-- ========= END OF CLASS DATA ========= -->
443<HR>
444
445
446<!-- ======= START OF BOTTOM NAVBAR ====== -->
447<A NAME="navbar_bottom"><!-- --></A>
448<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
449<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
450<TR>
451<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
452<A NAME="navbar_bottom_firstrow"><!-- --></A>
453<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
454  <TR ALIGN="center" VALIGN="top">
455  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
456  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
457  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
458  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/Executors.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
459  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
460  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
461  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
462  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
463  </TR>
464</TABLE>
465</TD>
466<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
467</EM>
468</TD>
469</TR>
470
471<TR>
472<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
473&nbsp;<A HREF="../../../../../com/google/common/util/concurrent/ExecutionList.html" title="class in com.google.common.util.concurrent"><B>PREV CLASS</B></A>&nbsp;
474&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>
475<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
476  <A HREF="../../../../../index.html?com/google/common/util/concurrent/Executors.html" target="_top"><B>FRAMES</B></A>  &nbsp;
477&nbsp;<A HREF="Executors.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
478&nbsp;<SCRIPT type="text/javascript">
479  <!--
480  if(window==top) {
481    document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
482  }
483  //-->
484</SCRIPT>
485<NOSCRIPT>
486  <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
487</NOSCRIPT>
488
489
490</FONT></TD>
491</TR>
492<TR>
493<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
494  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
495<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
496DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
497</TR>
498</TABLE>
499<A NAME="skip-navbar_bottom"></A>
500<!-- ======== END OF BOTTOM NAVBAR ======= -->
501
502<HR>
503
504</BODY>
505</HTML>
506