Top Description Inners Fields Constructors Methods
org.apache.tools.ant.taskdefs

pack-priv Class ProcessDestroyer

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable
Imports
java.lang.reflect.InvocationTargetException, .Method, java.util.HashSet, .Set

Destroys all registered Processes when the VM exits.
Since
Ant 1.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private boolean
private Method
private ProcessDestroyer.ProcessDestroyerImpl
private final Set<Process>
private Method
private boolean
private static final int

Constructor Summary

AccessConstructor and Description
pack-priv
ProcessDestroyer()

Constructs a ProcessDestroyer and obtains Runtime.addShutdownHook() and Runtime.removeShutdownHook() through reflection.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the specified Process was successfully added
add
(Process
the process to add
process
)

Returns true if the specified Process was successfully added to the list of processes to destroy upon VM exit.

private void
addShutdownHook()

Registers this ProcessDestroyer as a shutdown hook, uses reflection to ensure pre-JDK 1.3 compatibility.

public boolean

Returns:

true if this is currently added as shutdown hook
isAddedAsShutdownHook
()

Returns whether or not the ProcessDestroyer is registered as as shutdown hook

public boolean

Returns:

true if the specified Process was successfully removed
remove
(Process
the process to remove
process
)

Returns true if the specified Process was successfully removed from the list of processes to destroy upon VM exit.

private void
removeShutdownHook()

Removes this ProcessDestroyer as a shutdown hook, uses reflection to ensure pre-JDK 1.3 compatibility

public void
run()

Implements java.lang.Runnable.run.

Invoked by the VM when it is exiting.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

addedback to summary
private boolean added
addShutdownHookMethodback to summary
private Method addShutdownHookMethod
destroyProcessThreadback to summary
private ProcessDestroyer.ProcessDestroyerImpl destroyProcessThread
processesback to summary
private final Set<Process> processes
removeShutdownHookMethodback to summary
private Method removeShutdownHookMethod
runningback to summary
private boolean running
THREAD_DIE_TIMEOUTback to summary
private static final int THREAD_DIE_TIMEOUT

Constructor Detail

ProcessDestroyerback to summary
pack-priv ProcessDestroyer()

Constructs a ProcessDestroyer and obtains Runtime.addShutdownHook() and Runtime.removeShutdownHook() through reflection. The ProcessDestroyer manages a list of processes to be destroyed when the VM exits. If a process is added when the list is empty, this ProcessDestroyer is registered as a shutdown hook. If removing a process results in an empty list, the ProcessDestroyer is removed as a shutdown hook.

Method Detail

addback to summary
public boolean add(Process process)

Returns true if the specified Process was successfully added to the list of processes to destroy upon VM exit.

Parameters
process:Process

the process to add

Returns:boolean

true if the specified Process was successfully added

addShutdownHookback to summary
private void addShutdownHook()

Registers this ProcessDestroyer as a shutdown hook, uses reflection to ensure pre-JDK 1.3 compatibility.

isAddedAsShutdownHookback to summary
public boolean isAddedAsShutdownHook()

Returns whether or not the ProcessDestroyer is registered as as shutdown hook

Returns:boolean

true if this is currently added as shutdown hook

removeback to summary
public boolean remove(Process process)

Returns true if the specified Process was successfully removed from the list of processes to destroy upon VM exit.

Parameters
process:Process

the process to remove

Returns:boolean

true if the specified Process was successfully removed

removeShutdownHookback to summary
private void removeShutdownHook()

Removes this ProcessDestroyer as a shutdown hook, uses reflection to ensure pre-JDK 1.3 compatibility

runback to summary
public void run()

Implements java.lang.Runnable.run.

Invoked by the VM when it is exiting.

Annotations
@Override
org.apache.tools.ant.taskdefs back to summary

private Class ProcessDestroyer.ProcessDestroyerImpl

extends Thread
Class Inheritance

Field Summary

Modifier and TypeField and Description
private boolean
Inherited from java.lang.Thread:
MAX_PRIORITYMIN_PRIORITYNORM_PRIORITY

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

This method is run by the thread when it executes.
public void
setShouldDestroy(boolean shouldDestroy)

Inherited from java.lang.Thread:
activeCountcheckAccessclonecurrentThreaddumpStackenumerategetAllStackTracesgetContextClassLoadergetDefaultUncaughtExceptionHandlergetIdgetNamegetPrioritygetStackTracegetStategetThreadGroupgetUncaughtExceptionHandlerholdsLockinterruptinterruptedisAliveisDaemonisInterruptedisVirtualjoinjoinjoinjoinofPlatformofVirtualonSpinWaitresumesetContextClassLoadersetDaemonsetDefaultUncaughtExceptionHandlersetNamesetPrioritysetUncaughtExceptionHandlersleepsleepsleepstartstartVirtualThreadstopsuspendthreadIdtoStringyield

Field Detail

shouldDestroyback to summary
private boolean shouldDestroy

Constructor Detail

ProcessDestroyerImplback to summary
public ProcessDestroyerImpl()

Method Detail

runback to summary
public void run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

Doc from java.lang.Thread.run.

This method is run by the thread when it executes. Subclasses of Thread may override this method.

This method is not intended to be invoked directly. If this thread is a platform thread created with a Runnable task then invoking this method will invoke the task's run method. If this thread is a virtual thread then invoking this method directly does nothing.

Annotations
@Override
setShouldDestroyback to summary
public void setShouldDestroy(boolean shouldDestroy)