-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version 1.6.0 of the Amazon Kinesis Client Library
- Loading branch information
1 parent
b596a02
commit 97e606f
Showing
7 changed files
with
79 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/com/amazonaws/services/kinesis/clientlibrary/utils/NamedThreadFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.amazonaws.services.kinesis.clientlibrary.utils; | ||
|
||
import java.util.concurrent.Executors; | ||
import java.util.concurrent.ThreadFactory; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
|
||
/** | ||
* Custom thread factory that sets thread names based on the specified prefix. | ||
*/ | ||
public class NamedThreadFactory implements ThreadFactory { | ||
|
||
private String threadPrefix; | ||
private ThreadFactory defaultFactory = Executors.defaultThreadFactory(); | ||
private AtomicInteger counter = new AtomicInteger(0); | ||
|
||
/** | ||
* Construct a thread factory that uses the specified parameter as the thread prefix. | ||
* | ||
* @param threadPrefix the prefix with witch all created threads will be named | ||
*/ | ||
public NamedThreadFactory(String threadPrefix) { | ||
this.threadPrefix = threadPrefix; | ||
} | ||
|
||
@Override | ||
public Thread newThread(Runnable r) { | ||
Thread thread = defaultFactory.newThread(r); | ||
thread.setName(threadPrefix + counter.incrementAndGet()); | ||
return thread; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters