From 6c9280ac2a742e120fe197f3ad589bd77c4cbafe Mon Sep 17 00:00:00 2001 From: jofriedm-msft Date: Thu, 7 Sep 2017 09:55:39 -0700 Subject: [PATCH] Revert "thread pool in BlobOutputStreamInternal should be daemon" --- .../blob/BlobOutputStreamInternal.java | 37 +++++-------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobOutputStreamInternal.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobOutputStreamInternal.java index 0d3854373d764..44fde57d3f7a1 100644 --- a/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobOutputStreamInternal.java +++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobOutputStreamInternal.java @@ -27,8 +27,13 @@ import java.util.HashSet; import java.util.Set; import java.util.UUID; -import java.util.concurrent.*; -import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.Callable; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutorCompletionService; +import java.util.concurrent.Future; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; import com.microsoft.azure.storage.AccessCondition; import com.microsoft.azure.storage.Constants; @@ -46,29 +51,6 @@ */ final class BlobOutputStreamInternal extends BlobOutputStream { - private static class BlobOutputStreamThreadFactory implements ThreadFactory { - private final ThreadGroup group; - private final AtomicInteger threadNumber = new AtomicInteger(1); - private final String namePrefix; - - BlobOutputStreamThreadFactory() { - SecurityManager s = System.getSecurityManager(); - group = (s != null) ? s.getThreadGroup() : - Thread.currentThread().getThreadGroup(); - namePrefix = "azure-storage-bloboutputstream-thread-"; - } - - public Thread newThread(Runnable r) { - Thread t = new Thread(group, r, - namePrefix + threadNumber.getAndIncrement(), - 0); - t.setDaemon(true); - if (t.getPriority() != Thread.NORM_PRIORITY) - t.setPriority(Thread.NORM_PRIORITY); - return t; - } - } - /** * Holds the {@link AccessCondition} object that represents the access conditions for the blob. */ @@ -189,10 +171,9 @@ private BlobOutputStreamInternal(final CloudBlob parentBlob, final AccessConditi this.threadExecutor = new ThreadPoolExecutor( this.options.getConcurrentRequestCount(), this.options.getConcurrentRequestCount(), - 10, + 10, TimeUnit.SECONDS, - new LinkedBlockingQueue(), - new BlobOutputStreamThreadFactory()); + new LinkedBlockingQueue()); this.completionService = new ExecutorCompletionService(this.threadExecutor); }