- 浏览: 126960 次
- 性别:
- 来自: Singapore
文章分类
- 全部博客 (112)
- Tiger Thread (18)
- Perforce (6)
- Spring (5)
- maven (3)
- log4j (3)
- Quartz Scheduler (4)
- unix and linux (12)
- hibernate (3)
- Enum (1)
- Futures and Options (1)
- Market Making (2)
- Java Basic (11)
- Tibco EMS (3)
- F I X message (5)
- equity derivative (2)
- Sybase (3)
- XML (1)
- JUnit (2)
- J A X B 2.0 (1)
- N I O (1)
- windows batch file (1)
- Cruise Control (1)
- util Class (5)
- ant (1)
- JMS (1)
- profiling (0)
- Sql Server (6)
- GXT (2)
- eclipse (1)
- Generics (1)
- Tibco RV (3)
- Autosys (0)
- Message (1)
最新评论
-
houzhe11:
<property name="proxyTa ...
AOP usage -- BeanNameAutoProxyCreator usage
Executor is used to arrange thread execution. Basicly speaking, just manage, how many threads are permited to run together.
ExecutorService obj = Executors.newSingleThreadExecutor( ) -- only 1
ExecutorService obj = Executors.newFixedThreadPool(int poolSize) -- fix amount
ExecutorService obj = Executors.newCachedThreadPool( ) --- as many as it can
Code Sample
Executor e = Executors.newFixedThreadPool(5);
e.execute(new RunnableTask1( ));
e.execute(new RunnableTask2( ));
e.execute(new RunnableTask3( ));
While in another aritcle, you can see that, Executors.newFixedThreadPool(5) returns a ExecutorService. Actually, ExecutorService is a subclass of Executor, and it supplies more functionalities than Executor.
As far as ExecutorService is concerned, it supplies only one advanced function than Executor---how to stop the threads.
service.shutdownNow(); //Try to finish all Runnables(started and not started(in queue)), then, stop Executor.
service.shutdown(); //Directly stop the Executor, terminate running Runables, return back not started, yet in queue Runables.
There is a internal Queue maintained by ExecutorService. That's the core idea.
------------------------------------------------------------------------------------
Another point, Please pay attention to how they are used to different targets.
//FutureObject = ExecutorService.submit(Callable object);
//Executor.execut(Runnable object); //without any returns.
Future<BigInteger> prime1 = service.submit(new RandomPrimeSearch(512));
Future<BigInteger> prime2 = service.submit(new RandomPrimeSearch(512));
Future<BigInteger> prime3 = service.submit(new RandomPrimeSearch(512));
发表评论
-
javadoc for Cyclic Barrier
2009-04-24 12:48 905java.util.concurrent.CyclicBarr ... -
Delayed interface and Delay Queue
2009-04-22 17:42 1054/** * A standard implementati ... -
Count Down Latch example code
2009-04-22 10:38 1155Key point : 1) 1 task is co ... -
3 ways to break dead lock
2009-04-21 17:30 7621) supply special resources. ... -
Blocking Queue Usage
2009-04-20 11:21 8333 implementations: LinkedBlocki ... -
The usage of Lock and Condition
2009-04-18 12:31 1069//: concurrency/waxomatic2/WaxO ... -
Re entrantLock usage
2009-04-15 17:15 1320a thread can be really interru ... -
new interrupt in java5
2009-04-15 12:08 658In Java 5, Thread.interrupt() i ... -
interrupt
2009-04-15 10:57 8171) Each thread has a boolean in ... -
Executor Service Usage
2009-04-14 18:18 894ExecutorService exec = Executor ... -
Thread Local usage
2009-04-14 17:46 817ThreadLocal usage – from Javado ... -
Timer TimerTask usage
2009-04-14 12:03 725Timer typical usage new Tim ... -
wait, notify及线程通讯机制
2009-02-26 22:42 8511) wait(), notify() 方法被调用的时候,只要 ... -
Java Thread programming basical knowledge
2009-02-26 22:40 1090yield() : Give a hint to the th ... -
Count Down Latch explanation
2008-10-02 10:29 957Very important paragraph on how ... -
Scheduled Executor Service
2008-07-22 11:27 1107Executor can return Executor, E ... -
Callable Usage
2008-07-22 10:24 933The important thing need to loo ...
相关推荐
普罗米修斯执行者 ...Usage: ./prometheus-am-executor [options] script [args..] -f string YAML config file to use -l string HTTP Port to listen on (default ":8080") -v Enable verbose/debug log
Nagios分为服务器端(Nagios Core)和客户端(NRPE,Nagios Remote Plugin Executor)。服务器端负责监测和报警,客户端则执行实际的监控检查。在本案例中,我们将关注客户端的部署。 二、客户端安装 1. **nagios...
Intro Ambari 集成 Azkaban 使用前,先clone.代码到本地,选择合适你的分支版本。 Major Project Structure configuration : azkaban 配置文件 bin : Azkaban脚本修改(单机部署web、exec需要更换) ...Usage
3.4.1. 使用 Usage 3.4.2. 配置 Configuration 3.5. 支持的数据库 Supported databases 3.6. 创建数据库表 Creating the database tables 3.7. 数据库表名说明 Database table names explained...
The `execute` method sends a command to be executed by a command executor. - `driver_command`: The name of the command to execute as a string. - `params`: A dictionary of named parameters to send ...
检查`server.xml`中的`<Executor>`或`<Connector>`配置,确保线程池大小适中,避免过度创建线程。 2. **内存泄漏**:Java应用程序中的内存泄漏可能导致GC(垃圾收集)频繁运行,从而占用大量CPU。使用内存分析工具...
New abstractions to be covered include NetworkInterface, InterfaceAddress, Inet4/6Address, SocketAddress/InetSocketAddress, Executor, and others; extended access to low-level network information; ...
动态资源分配(Dynamic Allocation)在某些情况下可能并不理想,如长时间的executor空闲超时设置,可能导致在应用开始时效果明显,但随着作业运行,资源回收的开销反而降低了效率,表现为频繁的executor重启...
dl-推断性能 在pytorch / tensorflow和TensorRT / XLA / TVM上进行深度学习推理性能的性能分析。 环境环境 TVM 码头工人:nvidia / cuda:11.1.1-devel-...usage: executor.py [-h] [-w WARMUP] [-r ROUNDS] [-s SIZE]
7. **内存分析**: 使用`memory_get_usage()`和`memory_get_peak_usage()`检查内存使用情况,内存泄漏也可能导致CPU飙升。 8. **错误报告**: 检查错误日志,错误处理不当可能会导致无限循环或资源浪费。 9. **分析...
REXX(Regulated eXtended eXecutor)是一种高级过程编程语言,以其简洁的语法和强大的文本处理能力而闻名。在“REXX GCI-开源”项目中,GCI(Generic Call Interface)是REXX的一个关键组件,它为程序员提供了一种...
Performance and resource usage PEP 397: Python Launcher for Windows PEP 3151: Reworking the OS and IO exception hierarchy PEP 380: Syntax for Delegating to a Subgenerator PEP 409: Suppressing ...