diff --git a/src/Adaptive.Agrona/Adaptive.Agrona.csproj b/src/Adaptive.Agrona/Adaptive.Agrona.csproj
index 9a963368..9928db60 100644
--- a/src/Adaptive.Agrona/Adaptive.Agrona.csproj
+++ b/src/Adaptive.Agrona/Adaptive.Agrona.csproj
@@ -85,12 +85,14 @@
+
+
@@ -99,6 +101,7 @@
+
diff --git a/src/Adaptive.Agrona/Concurrent/AgentRunner.cs b/src/Adaptive.Agrona/Concurrent/AgentRunner.cs
index 5e9ad1d0..dabf793d 100644
--- a/src/Adaptive.Agrona/Concurrent/AgentRunner.cs
+++ b/src/Adaptive.Agrona/Concurrent/AgentRunner.cs
@@ -46,6 +46,7 @@ public AgentRunner(IIdleStrategy idleStrategy, ErrorHandler errorHandler, Atomic
/// Start the given agent runner on a new thread.
///
/// the agent runner to start
+ /// the new thread that has been started.
public static Thread StartOnThread(AgentRunner runner)
{
var thread = new Thread(runner.Run)
@@ -56,6 +57,20 @@ public static Thread StartOnThread(AgentRunner runner)
return thread;
}
+ ///
+ /// Start the given agent runner on a new thread.
+ ///
+ /// the agent runner to start
+ /// the factory to use to create the thread.
+ /// the new thread that has been started.
+ public static Thread StartOnThread(AgentRunner runner, IThreadFactory threadFactory)
+ {
+ var thread = threadFactory.NewThread(runner.Run);
+ thread.Name = runner.Agent().RoleName();
+ thread.Start();
+ return thread;
+ }
+
///
/// The who's lifecycle is being managed.
///
diff --git a/src/Adaptive.Agrona/Concurrent/DefaultThreadFactory.cs b/src/Adaptive.Agrona/Concurrent/DefaultThreadFactory.cs
new file mode 100644
index 00000000..2f9551e3
--- /dev/null
+++ b/src/Adaptive.Agrona/Concurrent/DefaultThreadFactory.cs
@@ -0,0 +1,12 @@
+using System.Threading;
+
+namespace Adaptive.Agrona.Concurrent
+{
+ public class DefaultThreadFactory : IThreadFactory
+ {
+ public Thread NewThread(ThreadStart runner)
+ {
+ return new Thread(runner);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Adaptive.Agrona/Concurrent/IThreadFactory.cs b/src/Adaptive.Agrona/Concurrent/IThreadFactory.cs
new file mode 100644
index 00000000..031861e4
--- /dev/null
+++ b/src/Adaptive.Agrona/Concurrent/IThreadFactory.cs
@@ -0,0 +1,10 @@
+using System;
+using System.Threading;
+
+namespace Adaptive.Agrona.Concurrent
+{
+ public interface IThreadFactory
+ {
+ Thread NewThread(ThreadStart runner);
+ }
+}
\ No newline at end of file