Skip to content

Commit

Permalink
Merge pull request Azure#214 from Azure/revert-211-make_theadpool_daemon
Browse files Browse the repository at this point in the history
Revert "thread pool in BlobOutputStreamInternal should be daemon"
  • Loading branch information
jofriedm-msft authored Sep 7, 2017
2 parents 103e53b + 6c9280a commit d54bf94
Showing 1 changed file with 9 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
*/
Expand Down Expand Up @@ -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<Runnable>(),
new BlobOutputStreamThreadFactory());
new LinkedBlockingQueue<Runnable>());
this.completionService = new ExecutorCompletionService<Void>(this.threadExecutor);
}

Expand Down

0 comments on commit d54bf94

Please sign in to comment.