Example usage for org.apache.commons.io FileCleaner exitWhenFinished

List of usage examples for org.apache.commons.io FileCleaner exitWhenFinished

Introduction

In this page you can find the example usage for org.apache.commons.io FileCleaner exitWhenFinished.

Prototype

public static synchronized void exitWhenFinished() 

Source Link

Document

Call this method to cause the file cleaner thread to terminate when there are no more objects being tracked for deletion.

Usage

From source file:org.apache.tapestry5.upload.modules.UploadModule.java

@Scope(ScopeConstants.PERTHREAD)
public static MultipartDecoder buildMultipartDecoder(PerthreadManager perthreadManager,

        RegistryShutdownHub shutdownHub,

        @Autobuild MultipartDecoderImpl multipartDecoder) {
    // This is proabably overkill since the FileCleaner should catch temporary files, but lets
    // be safe.//from  w w  w  .j  a  va  2  s  .  c o m
    perthreadManager.addThreadCleanupListener(multipartDecoder);

    if (needToAddShutdownListener.getAndSet(false)) {
        shutdownHub.addRegistryShutdownListener(new Runnable() {
            public void run() {
                FileCleaner.exitWhenFinished();
            }
        });
    }

    return multipartDecoder;
}