executors.html
来自「j2se5-api-zh,java文档的中文版本」· HTML 代码 · 共 703 行 · 第 1/3 页
HTML
703 行
<!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.5.0_03) on Wed Nov 02 09:51:41 CST 2005 --><META http-equiv="Content-Type" content="text/html; charset=gb2312"><TITLE>Executors (Java 2 Platform SE 5.0)</TITLE><META NAME="keywords" CONTENT="java.util.concurrent.Executors class"><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){ parent.document.title="Executors (Java 2 Platform SE 5.0)";}</SCRIPT><NOSCRIPT></NOSCRIPT></HEAD><BODY BGCOLOR="white" onload="windowTitle();"><!-- ========= START OF TOP NAVBAR ======= --><A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="跳过导航链接"></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>概述</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>软件包</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>类</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Executors.html"><FONT CLASS="NavBarFont1"><B>使用</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>树</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>已过时</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>索引</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>帮助</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Standard Ed. 5.0</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="ExecutorCompletionService.html" title="java.util.concurrent 中的类"><B>上一个类</B></A> <A HREF="ExecutorService.html" title="java.util.concurrent 中的接口"><B>下一个类</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html@java_2Futil_2Fconcurrent_2FExecutors.html" target="_top"><B>框架</B></A> <A HREF="Executors.html" target="_top"><B>无框架</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../allclasses-noframe.html"><B>所有类</B></A>'); } //--></SCRIPT><NOSCRIPT> <A HREF="../../../allclasses-noframe.html"><B>所有类</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 摘要: 嵌套 | 字段 | 构造方法 | <A HREF="#method_summary">方法</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">详细信息: 字段 | 构造方法 | <A HREF="#method_detail">方法</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">java.util.concurrent</FONT><BR>类 Executors</H2><PRE><A HREF="../../lang/Object.html" title="java.lang 中的类">java.lang.Object</A> <IMG SRC="../../../resources/inherit.gif" ALT="继承者 "><B>java.util.concurrent.Executors</B></PRE><HR><DL><DT><PRE>public class <B>Executors</B><DT>extends <A HREF="../../lang/Object.html" title="java.lang 中的类">Object</A></DL></PRE><P>此包中所定义的 <A HREF="Executor.html" title="java.util.concurrent 中的接口"><CODE>Executor</CODE></A>、<A HREF="ExecutorService.html" title="java.util.concurrent 中的接口"><CODE>ExecutorService</CODE></A>、<A HREF="ScheduledExecutorService.html" title="java.util.concurrent 中的接口"><CODE>ScheduledExecutorService</CODE></A>、<A HREF="ThreadFactory.html" title="java.util.concurrent 中的接口"><CODE>ThreadFactory</CODE></A> 和 <A HREF="Callable.html" title="java.util.concurrent 中的接口"><CODE>Callable</CODE></A> 类的工厂和实用方法。此类支持以下各种方法: <ul><li> 创建并返回设置有常用配置字符串的 <A HREF="ExecutorService.html" title="java.util.concurrent 中的接口"><CODE>ExecutorService</CODE></A> 的方法。 <li> 创建并返回设置有常用配置字符串的 <A HREF="ScheduledExecutorService.html" title="java.util.concurrent 中的接口"><CODE>ScheduledExecutorService</CODE></A> 的方法。 <li> 创建并返回“包装的”ExecutorService 方法,它通过使特定于实现的方法不可访问来禁用重新配置。<li> 创建并返回 <A HREF="ThreadFactory.html" title="java.util.concurrent 中的接口"><CODE>ThreadFactory</CODE></A> 的方法,它可将新创建的线程设置为已知的状态。<li> 创建并返回非闭包形式的 <A HREF="Callable.html" title="java.util.concurrent 中的接口"><CODE>Callable</CODE></A> 的方法,这样可将其用于需要 <tt>Callable</tt> 的执行方法中。 </ul><P><P><DL><DT><B>从以下版本开始:</B></DT> <DD>1.5</DD></DL><HR><P><!-- ========== 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>方法摘要</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="Callable.html" title="java.util.concurrent 中的接口">Callable</A><<A HREF="../../lang/Object.html" title="java.lang 中的类">Object</A>></CODE></FONT></TD><TD><CODE><B><A HREF="Executors.html#callable(java.security.PrivilegedAction)">callable</A></B>(java.security.PrivilegedAction action)</CODE><BR> 返回 <A HREF="Callable.html" title="java.util.concurrent 中的接口"><CODE>Callable</CODE></A> 对象,调用它时可运行给定特权的操作并返回其结果。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="Callable.html" title="java.util.concurrent 中的接口">Callable</A><<A HREF="../../lang/Object.html" title="java.lang 中的类">Object</A>></CODE></FONT></TD><TD><CODE><B><A HREF="Executors.html#callable(java.security.PrivilegedExceptionAction)">callable</A></B>(java.security.PrivilegedExceptionAction action)</CODE><BR> 返回 <A HREF="Callable.html" title="java.util.concurrent 中的接口"><CODE>Callable</CODE></A> 对象,调用它时可运行给定特权的异常操作并返回其结果。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="Callable.html" title="java.util.concurrent 中的接口">Callable</A><<A HREF="../../lang/Object.html" title="java.lang 中的类">Object</A>></CODE></FONT></TD><TD><CODE><B><A HREF="Executors.html#callable(java.lang.Runnable)">callable</A></B>(<A HREF="../../lang/Runnable.html" title="java.lang 中的接口">Runnable</A> task)</CODE><BR> 返回 <A HREF="Callable.html" title="java.util.concurrent 中的接口"><CODE>Callable</CODE></A> 对象,调用它时可运行给定的任务并返回 <tt>null</tt>。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""><TR ALIGN="right" VALIGN=""><TD NOWRAP><FONT SIZE="-1"><CODE><T> <A HREF="Callable.html" title="java.util.concurrent 中的接口">Callable</A><T></CODE></FONT></TD></TR></TABLE></CODE></FONT></TD><TD><CODE><B><A HREF="Executors.html#callable(java.lang.Runnable, T)">callable</A></B>(<A HREF="../../lang/Runnable.html" title="java.lang 中的接口">Runnable</A> task, T result)</CODE><BR> 返回 <A HREF="Callable.html" title="java.util.concurrent 中的接口"><CODE>Callable</CODE></A> 对象,调用它时可运行给定的任务并返回给定的结果。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="ThreadFactory.html" title="java.util.concurrent 中的接口">ThreadFactory</A></CODE></FONT></TD><TD><CODE><B><A HREF="Executors.html#defaultThreadFactory()">defaultThreadFactory</A></B>()</CODE><BR> 返回用于创建新线程的默认线程工厂。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="ExecutorService.html" title="java.util.concurrent 中的接口">ExecutorService</A></CODE></FONT></TD><TD><CODE><B><A HREF="Executors.html#newCachedThreadPool()">newCachedThreadPool</A></B>()</CODE><BR> 创建一个可根据需要创建新线程的线程池,但是在以前构造的线程可用时将重用它们。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="ExecutorService.html" title="java.util.concurrent 中的接口">ExecutorService</A></CODE></FONT></TD><TD><CODE><B><A HREF="Executors.html#newCachedThreadPool(java.util.concurrent.ThreadFactory)">newCachedThreadPool</A></B>(<A HREF="ThreadFactory.html" title="java.util.concurrent 中的接口">ThreadFactory</A> threadFactory)</CODE><BR> 创建一个可根据需要创建新线程的线程池,但是在以前构造的线程可用时将重用它们,并在需要时使用提供的 ThreadFactory 创建新线程。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="ExecutorService.html" title="java.util.concurrent 中的接口">ExecutorService</A></CODE></FONT></TD><TD><CODE><B><A HREF="Executors.html#newFixedThreadPool(int)">newFixedThreadPool</A></B>(int nThreads)</CODE><BR> 创建一个可重用固定线程集合的线程池,以共享的无界队列方式来运行这些线程。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="ExecutorService.html" title="java.util.concurrent 中的接口">ExecutorService</A></CODE></FONT></TD><TD><CODE><B><A HREF="Executors.html#newFixedThreadPool(int, java.util.concurrent.ThreadFactory)">newFixedThreadPool</A></B>(int nThreads, <A HREF="ThreadFactory.html" title="java.util.concurrent 中的接口">ThreadFactory</A> threadFactory)</CODE><BR> 创建一个可重用固定线程集合的线程池,以共享的无界队列方式来运行这些线程,在需要时使用提供的 ThreadFactory 创建新线程。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="ScheduledExecutorService.html" title="java.util.concurrent 中的接口">ScheduledExecutorService</A></CODE></FONT></TD><TD><CODE><B><A HREF="Executors.html#newScheduledThreadPool(int)">newScheduledThreadPool</A></B>(int corePoolSize)</CODE><BR> 创建一个线程池,它可安排在给定延迟后运行命令或者定期地执行。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="ScheduledExecutorService.html" title="java.util.concurrent 中的接口">ScheduledExecutorService</A></CODE></FONT></TD><TD><CODE><B><A HREF="Executors.html#newScheduledThreadPool(int, java.util.concurrent.ThreadFactory)">newScheduledThreadPool</A></B>(int corePoolSize, <A HREF="ThreadFactory.html" title="java.util.concurrent 中的接口">ThreadFactory</A> threadFactory)</CODE><BR> 创建一个线程池,它可安排在给定延迟后运行命令或者定期地执行。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="ExecutorService.html" title="java.util.concurrent 中的接口">ExecutorService</A></CODE></FONT></TD><TD><CODE><B><A HREF="Executors.html#newSingleThreadExecutor()">newSingleThreadExecutor</A></B>()</CODE><BR> 创建一个使用单个 worker 线程的 Executor,以无界队列方式来运行该线程。</TD></TR>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?