|
27 | 27 | import java.util.HashSet; |
28 | 28 | import java.util.Set; |
29 | 29 | import java.util.UUID; |
30 | | -import java.util.concurrent.*; |
31 | | -import java.util.concurrent.atomic.AtomicInteger; |
| 30 | +import java.util.concurrent.Callable; |
| 31 | +import java.util.concurrent.ConcurrentHashMap; |
| 32 | +import java.util.concurrent.ExecutorCompletionService; |
| 33 | +import java.util.concurrent.Future; |
| 34 | +import java.util.concurrent.LinkedBlockingQueue; |
| 35 | +import java.util.concurrent.ThreadPoolExecutor; |
| 36 | +import java.util.concurrent.TimeUnit; |
32 | 37 |
|
33 | 38 | import com.microsoft.azure.storage.AccessCondition; |
34 | 39 | import com.microsoft.azure.storage.Constants; |
|
46 | 51 | */ |
47 | 52 | final class BlobOutputStreamInternal extends BlobOutputStream { |
48 | 53 |
|
49 | | - private static class BlobOutputStreamThreadFactory implements ThreadFactory { |
50 | | - private final ThreadGroup group; |
51 | | - private final AtomicInteger threadNumber = new AtomicInteger(1); |
52 | | - private final String namePrefix; |
53 | | - |
54 | | - BlobOutputStreamThreadFactory() { |
55 | | - SecurityManager s = System.getSecurityManager(); |
56 | | - group = (s != null) ? s.getThreadGroup() : |
57 | | - Thread.currentThread().getThreadGroup(); |
58 | | - namePrefix = "azure-storage-bloboutputstream-thread-"; |
59 | | - } |
60 | | - |
61 | | - public Thread newThread(Runnable r) { |
62 | | - Thread t = new Thread(group, r, |
63 | | - namePrefix + threadNumber.getAndIncrement(), |
64 | | - 0); |
65 | | - t.setDaemon(true); |
66 | | - if (t.getPriority() != Thread.NORM_PRIORITY) |
67 | | - t.setPriority(Thread.NORM_PRIORITY); |
68 | | - return t; |
69 | | - } |
70 | | - } |
71 | | - |
72 | 54 | /** |
73 | 55 | * Holds the {@link AccessCondition} object that represents the access conditions for the blob. |
74 | 56 | */ |
@@ -189,10 +171,9 @@ private BlobOutputStreamInternal(final CloudBlob parentBlob, final AccessConditi |
189 | 171 | this.threadExecutor = new ThreadPoolExecutor( |
190 | 172 | this.options.getConcurrentRequestCount(), |
191 | 173 | this.options.getConcurrentRequestCount(), |
192 | | - 10, |
| 174 | + 10, |
193 | 175 | TimeUnit.SECONDS, |
194 | | - new LinkedBlockingQueue<Runnable>(), |
195 | | - new BlobOutputStreamThreadFactory()); |
| 176 | + new LinkedBlockingQueue<Runnable>()); |
196 | 177 | this.completionService = new ExecutorCompletionService<Void>(this.threadExecutor); |
197 | 178 | } |
198 | 179 |
|
|
0 commit comments