|
JavaTM Platform Standard Ed. 6 |
|||||||||
전의 클래스 다음의 클래스 | 프레임 있어 프레임 없음 | |||||||||
개요 : 상자 | 필드 | 생성자 | 메소드 | 상세: 필드 | 생성자 | 메소드 |
java.lang.Objectjava.util.concurrent.AbstractExecutorService
java.util.concurrent.ThreadPoolExecutor
java.util.concurrent.ScheduledThreadPoolExecutor
public class ScheduledThreadPoolExecutor
지정된 지연 시간 후 또는 정기적으로 커멘드를 실행하도록(듯이) 추가로 스케줄 할 수 있는 ThreadPoolExecutor
입니다. 복수의 워크스 레드가 필요한 경우, 또는 이 클래스가 확장하는 ThreadPoolExecutor
가 가지고 말이야들 되는 유연성이나 기능이 요구되는 경우는,Timer
보다 이 클래스를 사용하는 것을 추천합니다.
지연 태스크는 유효하게 되자마자 실행됩니다만, 유효하게 된 뒤 언제 개시될까에 대해서는, 리얼타임 보증이 없습니다. 완전히 같은 실행 시각에 스케줄 설정된 태스크는, 송신의 선입선출 (FIFO) 순서에 유효하게 됩니다.
이 클래스는 ThreadPoolExecutor
로부터 상속됩니다만, 상속된 튜닝 메소드의 일부는 유용하지는 않습니다. 특히,corePoolSize thread와 안 바운드 형식의 큐를 사용하는 고정 사이즈 풀로서 동작하기 위해(때문에),maximumPoolSize 를 조정해도 유익한 결과는 얻을 수 있지 않습니다.
확장의 주의: 이 클래스는 AbstractExecutorService
submit 메소드를 오버라이드(override) 해, 태스크 단위의 지연과 스케줄링을 제어하는 내부 객체를 생성합니다. 기능을 보호하기 위해서, 서브 클래스에서 이러한 메소드를 더 이상 오버라이드(override) 하는 경우는, 슈퍼 클래스 버젼을 호출할 필요가 있습니다. 이것에 의해, 태스크의 추가의 커스터마이즈가 실질적으로 무효가 됩니다. 다만 이 태스크에서는, 대체의 protected 확장 메소드 decorateTask (Runnable 와 Callable 마다 1 버젼씩)가 준비되어 있습니다. 이것은,execute,submit,schedule,scheduleAtFixedRate, 및 scheduleWithFixedDelay 로 입력된 커멘드를 실행하기 위한 구상 태스크형을 커스터마이즈 하기 위해서 사용할 수 있습니다. 디폴트로 ScheduledThreadPoolExecutor 는 FutureTask
를 확장하는 태스크형을 사용합니다. 다만 다음과 같은 형식의 서브 클래스를 사용해, 변경 또는 치환할 수 있습니다.
public class CustomScheduledExecutor extends ScheduledThreadPoolExecutor { static class CustomTask<V> implements RunnableScheduledFuture<V> { ... } protected <V> RunnableScheduledFuture<V> decorateTask( Runnable r, RunnableScheduledFuture<V> task) { return new CustomTask<V>(r, task); } protected <V> RunnableScheduledFuture<V> decorateTask( Callable<V> c, RunnableScheduledFuture<V> task) { return new CustomTask<V>(c, task); } // ... add constructors, etc. }
상자의 클래스의 개요 |
---|
클래스 java.util.concurrent. ThreadPoolExecutor 로부터 상속된 상자의 클래스/인터페이스 |
---|
ThreadPoolExecutor.AbortPolicy , ThreadPoolExecutor.CallerRunsPolicy , ThreadPoolExecutor.DiscardOldestPolicy , ThreadPoolExecutor.DiscardPolicy |
생성자 의 개요 | |
---|---|
ScheduledThreadPoolExecutor (int corePoolSize)
지정된 코어 풀 사이즈로, 새로운 ScheduledThreadPoolExecutor 를 작성합니다. |
|
ScheduledThreadPoolExecutor (int corePoolSize,
RejectedExecutionHandler handler)
지정된 초기 파라미터를 사용해, 새로운 ScheduledThreadPoolExecutor 를 작성합니다. |
|
ScheduledThreadPoolExecutor (int corePoolSize,
ThreadFactory threadFactory)
지정된 초기 파라미터를 사용해, 새로운 ScheduledThreadPoolExecutor 를 작성합니다. |
|
ScheduledThreadPoolExecutor (int corePoolSize,
ThreadFactory threadFactory,
RejectedExecutionHandler handler)
지정된 초기 파라미터를 사용해, 새로운 ScheduledThreadPoolExecutor 를 작성합니다. |
메소드의 개요 | ||
---|---|---|
protected
|
decorateTask (Callable <V> callable,
RunnableScheduledFuture <V> task)
호출 가능 레이아웃을 실행하기 위해서 사용하는 태스크를 변경 또는 치환합니다. |
|
protected
|
decorateTask (Runnable runnable,
RunnableScheduledFuture <V> task)
runnable 를 실행하기 위해서 사용하는 태스크를 변경 또는 치환합니다. |
|
void |
execute (Runnable command)
요구된 지연이 제로로, command 를 실행합니다. |
|
boolean |
getContinueExistingPeriodicTasksAfterShutdownPolicy ()
기존의 정기적인 태스크의 실행을 계속할지 어떨지에 관한 정책를 가져옵니다. |
|
boolean |
getExecuteExistingDelayedTasksAfterShutdownPolicy ()
기존의 지연 태스크를 실행할지 어떨지에 관한 정책를 가져옵니다. |
|
BlockingQueue <Runnable > |
getQueue ()
이 executor 로 사용하는 태스크 큐를 돌려줍니다. |
|
boolean |
remove (Runnable task)
executor 의 내부 큐에 이 태스크가 존재하는 경우는 삭제하기 위해(때문에), 그 태스크가 아직 개시되어 있지 않은 경우는 실행되지 않습니다. |
|
|
schedule (Callable <V> callable,
long delay,
TimeUnit unit)
지정된 지연 후에 유효하게 되는 ScheduledFuture 를 작성해 실행합니다. |
|
ScheduledFuture <? > |
schedule (Runnable command,
long delay,
TimeUnit unit)
지정된 지연 후에 유효하게 되는 단발적인 액션을 작성해 실행합니다. |
|
ScheduledFuture <? > |
scheduleAtFixedRate (Runnable command,
long initialDelay,
long period,
TimeUnit unit)
지정된 초기 지연의 경과후에 처음 유효하게 되어, 그 후는 지정된 기간 마다 유효하게 되는 정기적인 액션을 작성해 실행합니다. |
|
ScheduledFuture <? > |
scheduleWithFixedDelay (Runnable command,
long initialDelay,
long delay,
TimeUnit unit)
지정된 초기 지연의 경과후에 처음 유효하게 되어, 그 후는 실행의 종료후부터 다음의 개시까지의 지정의 지연 마다 유효하게 되는 정기적인 액션을 작성해 실행합니다. |
|
void |
setContinueExistingPeriodicTasksAfterShutdownPolicy (boolean value)
기존의 정기적인 태스크의 실행을 계속할지 어떨지에 관한 정책를 설정합니다. |
|
void |
setExecuteExistingDelayedTasksAfterShutdownPolicy (boolean value)
기존의 지연 태스크를 실행할지 어떨지에 관한 정책를 설정합니다. |
|
void |
shutdown ()
순서 올바르게 종료을 개시합니다. |
|
List <Runnable > |
shutdownNow ()
실행중의 액티브한 태스크 모든 정지를 시도해 대기중의 태스크의 처리를 정지해, 실행을 대기하고 있던 태스크의 리스트를 돌려줍니다. |
|
|
submit (Callable <T> task)
값을 돌려주는 실행용 태스크를 송신해, 보류 상태의 태스크 결과를 나타내는 Future 를 돌려줍니다. |
|
Future <? > |
submit (Runnable task)
실행용의 Runnable 태스크를 송신해, 그 태스크를 나타내는 Future 를 돌려줍니다. |
|
|
submit (Runnable task,
T result)
실행용의 Runnable 태스크를 송신해, 그 태스크를 나타내는 Future 를 돌려줍니다. |
클래스 java.util.concurrent. ThreadPoolExecutor 로부터 상속된 메소드 |
---|
afterExecute , allowCoreThreadTimeOut , allowsCoreThreadTimeOut , awaitTermination , beforeExecute , finalize , getActiveCount , getCompletedTaskCount , getCorePoolSize , getKeepAliveTime , getLargestPoolSize , getMaximumPoolSize , getPoolSize , getRejectedExecutionHandler , getTaskCount , getThreadFactory , isShutdown , isTerminated , isTerminating , prestartAllCoreThreads , prestartCoreThread , purge , setCorePoolSize , setKeepAliveTime , setMaximumPoolSize , setRejectedExecutionHandler , setThreadFactory , terminated |
클래스 java.util.concurrent. AbstractExecutorService 로부터 상속된 메소드 |
---|
invokeAll , invokeAll , invokeAny , invokeAny , newTaskFor , newTaskFor |
클래스 java.lang. Object 로부터 상속된 메소드 |
---|
clone , equals , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait |
인터페이스 java.util.concurrent. ExecutorService 로부터 상속된 메소드 |
---|
awaitTermination , invokeAll , invokeAll , invokeAny , invokeAny , isShutdown , isTerminated |
생성자 의 상세 |
---|
public ScheduledThreadPoolExecutor(int corePoolSize)
corePoolSize
- 풀내 로 유지하는 thread의 수 (IDLE 상태의 thread도 포함한다)
IllegalArgumentException
- corePoolSize < 0 의 경우public ScheduledThreadPoolExecutor(int corePoolSize, ThreadFactory threadFactory)
corePoolSize
- 풀내 로 유지하는 thread의 수 (IDLE 상태의 thread도 포함한다)threadFactory
- executor 가 새로운 thread를 작성할 경우에 사용하는 팩토리
IllegalArgumentException
- corePoolSize < 0 의 경우
NullPointerException
- threadFactory 가 null 의 경우public ScheduledThreadPoolExecutor(int corePoolSize, RejectedExecutionHandler handler)
corePoolSize
- 풀내 로 유지하는 thread의 수 (IDLE 상태의 thread도 포함한다)handler
- thread의 경계 및 큐의 용량에 이르렀기 때문에, 실행이 블록 되었을 때에 사용하는 핸들러
IllegalArgumentException
- corePoolSize < 0 의 경우
NullPointerException
- 핸들러가 null 의 경우public ScheduledThreadPoolExecutor(int corePoolSize, ThreadFactory threadFactory, RejectedExecutionHandler handler)
corePoolSize
- 풀내 로 유지하는 thread의 수 (IDLE 상태의 thread도 포함한다)threadFactory
- executor 가 새로운 thread를 작성할 경우에 사용하는 팩토리handler
- thread의 경계 및 큐의 용량에 이르렀기 때문에, 실행이 블록 되었을 때에 사용하는 핸들러
IllegalArgumentException
- corePoolSize < 0 의 경우
NullPointerException
- threadFactory 또는 핸들러가 null 의 경우메소드의 상세 |
---|
public boolean remove(Runnable task)
ThreadPoolExecutor
의 기술: 이 메소드는 취소해 방식의 일부로서 편리한 일이 있습니다. 내부 큐에 배치되기 전에 다른 형식에 변환된 태스크는, 삭제에 실패할 가능성이 있습니다. 예를 들어,submit 를 사용해 들어가는 태스크는,Future 상태를 유지하는 형식에 변환되는 일이 있습니다. 다만, 이 경우는,ThreadPoolExecutor.purge()
메소드를 사용해, 삭제된 Future 를 삭제할 수가 있습니다.
ThreadPoolExecutor
내의 remove
task
- 삭제하는 태스크
protected <V> RunnableScheduledFuture <V> decorateTask(Runnable runnable, RunnableScheduledFuture <V> task)
runnable
- 송신된 Runnabletask
- runnable 를 실행하기 위해서 작성된 태스크
protected <V> RunnableScheduledFuture <V> decorateTask(Callable <V> callable, RunnableScheduledFuture <V> task)
callable
- 송신된 Callabletask
- 호출 가능 레이아웃을 실행하기 위해서 작성된 태스크
public ScheduledFuture <? > schedule(Runnable command, long delay, TimeUnit unit)
ScheduledExecutorService
의 기술:
ScheduledExecutorService
내의 schedule
command
- 실행하는 태스크delay
- 현재부터 지연 실행까지의 시간unit
- delay 파라미터의 시간 단위
public <V> ScheduledFuture <V> schedule(Callable <V> callable, long delay, TimeUnit unit)
ScheduledExecutorService
의 기술:
ScheduledExecutorService
내의 schedule
callable
- 실행하는 함수delay
- 현재부터 지연 실행까지의 시간unit
- delay 파라미터의 시간 단위
public ScheduledFuture <? > scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)
ScheduledExecutorService
의 기술:
ScheduledExecutorService
내의 scheduleAtFixedRate
command
- 실행하는 태스크initialDelay
- 최초의 지연 실행까지의 시간period
- 연속하는 실행의 간격unit
- initialDelay 및 period 파라미터의 시간 단위
public ScheduledFuture <? > scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)
ScheduledExecutorService
의 기술:
ScheduledExecutorService
내의 scheduleWithFixedDelay
command
- 실행하는 태스크initialDelay
- 최초의 지연 실행까지의 시간delay
- 실행의 종료후부터 다음의 개시까지의 지연unit
- initialDelay 및 delay 파라미터의 시간 단위
public void execute(Runnable command)
ScheduledFuture
에 액세스 합니다.
Executor
내의 execute
ThreadPoolExecutor
내의 execute
command
- 실행하는 태스크
RejectedExecutionException
- RejectedExecutionHandler 의 판단으로, executor 가 종료 되었기 때문에 태스크의 실행을 받아들일 수가 없는 경우
NullPointerException
- 커멘드가 null 의 경우public Future <? > submit(Runnable task)
ExecutorService
의 기술:
ExecutorService
내의 submit
AbstractExecutorService
내의 submit
task
- 송신하는 태스크
public <T> Future <T> submit(Runnable task, T result)
ExecutorService
의 기술:
ExecutorService
내의 submit
AbstractExecutorService
내의 submit
task
- 송신하는 태스크result
- 돌려주는 결과
public <T> Future <T> submit(Callable <T> task)
ExecutorService
의 기술:태스크의 대기를 즉시 블록 하는 경우는,result = exec.submit(aCallable). get(); 의 형식의 구축을 사용할 수 있습니다.
주:Executors
클래스에는, 크로 전기밥통을 닮은 다른 일반 객체를 변환할 수 있는 메소드 세트가 포함됩니다. 예를 들어,PrivilegedAction
를 Callable
형식으로 변환해, 송신 가능하게 할 수가 있습니다.
ExecutorService
내의 submit
AbstractExecutorService
내의 submit
task
- 송신하는 태스크
public void setContinueExistingPeriodicTasksAfterShutdownPolicy(boolean value)
value
- true 의 경우는 종료 후에 속행해, 그렇지 않은 경우는 속행하지 않는getContinueExistingPeriodicTasksAfterShutdownPolicy()
public boolean getContinueExistingPeriodicTasksAfterShutdownPolicy()
setContinueExistingPeriodicTasksAfterShutdownPolicy(boolean)
public void setExecuteExistingDelayedTasksAfterShutdownPolicy(boolean value)
value
- true 의 경우는 종료 후에 실행해, 그렇지 않은 경우는 실행하지 않는getExecuteExistingDelayedTasksAfterShutdownPolicy()
public boolean getExecuteExistingDelayedTasksAfterShutdownPolicy()
setExecuteExistingDelayedTasksAfterShutdownPolicy(boolean)
public void shutdown()
ExecutorService
내의 shutdown
ThreadPoolExecutor
내의 shutdown
public List <Runnable > shutdownNow()
실행중의 액티브한 태스크 처리를 정지하기 위해서 최선의 노력을 하는 것 이상의 보증은 없습니다. 이 구현에서는,Thread.interrupt()
를 개입시켜 태스크를 취소하기 (위해)때문에, 인터럽트에 대한 응답에 실패한 태스크는 종료하지 않게 될 가능성이 있습니다.
ExecutorService
내의 shutdownNow
ThreadPoolExecutor
내의 shutdownNow
ScheduledFuture
이며,execute 를 사용해 송신된 태스크가 포함된다. 이러한 태스크는 스케줄링용이며, 지연이 제로의 ScheduledFuture 의 기초로서 사용된다
SecurityException
- 시큐리티 매니저가 존재하는 상황으로 이 ExecutorService 의 종료을 실행하면(자), 호출 측에는 변경을 허가하지 않는 thread를 조작할 수 있는 경우. 이것은,RuntimePermission
("modifyThread") 를 보관 유지하지 않는지, 시큐리티 매니저의 checkAccess 메소드가 액세스를 거부하기 위해(때문에)이다public BlockingQueue <Runnable > getQueue()
ScheduledFuture
이며,execute 를 사용해 송신된 태스크가 포함됩니다. 이러한 태스크는 스케줄링용이며, 지연이 제로의 ScheduledFuture 의 기초로서 사용됩니다. 이 큐에 대한 반복 처리에서는, 태스크가 실행 순서로 횡단(traverse) 되는 것은 보증되지 않습니다.
ThreadPoolExecutor
내의 getQueue
|
JavaTM Platform Standard Ed. 6 |
|||||||||
전의 클래스 다음의 클래스 | 프레임 있어 프레임 없음 | |||||||||
개요 : 상자 | 필드 | 생성자 | 메소드 | 상세: 필드 | 생성자 | 메소드 |
Copyright 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms . Documentation Redistribution Policy 도 참조해 주세요.