public static UploadMonitor create ( TransferManager manager , UploadImpl transfer , ExecutorService threadPool , UploadCallable multipartUploadCallable , PutObjectRequest putObjectRequest , ProgressListenerChain progressListenerChain ) { UploadMonitor uploadMonitor = new UploadMonitor ( manager , transfer , threadPool , multipartUploadCallable , putObjectRequest , progressListenerChain ) ; Future < UploadResult > thisFuture = threadPool . submit ( uploadMonitor ) ; // Use an atomic compareAndSet to prevent a possible race between the // setting of the UploadMonitor's futureReference, and setting the // CompleteMultipartUpload's futureReference within the call() method. // We only want to set the futureReference to UploadMonitor's futureReference if the // current value is null, otherwise the futureReference that's set is // CompleteMultipartUpload's which is ultimately what we want. uploadMonitor . futureReference . compareAndSet ( null , thisFuture ) ; return uploadMonitor ; }
Constructs a new upload watcher and then immediately submits it to the thread pool .