Skip to content
Snippets Groups Projects
Commit 107442a4 authored by Nelson Tavares de Sousa's avatar Nelson Tavares de Sousa
Browse files

refactored configureThread to return a Thread

parent 6f8a8aab
No related branches found
No related tags found
No related merge requests found
......@@ -136,27 +136,21 @@ public final class Analysis<T extends AnalysisConfiguration> implements Uncaught
newListener = factory.create();
switch (stage.getTerminationStrategy()) {
case BY_SIGNAL: {
final RunnableConsumerStage runnableConsumerStage = new RunnableConsumerStage(stage);
final Thread thread = new Thread(runnableConsumerStage);
final RunnableConsumerStage runnable = new RunnableConsumerStage(stage);
final Thread thread = createThread(newListener, intraStages, stage, runnable);
this.consumerThreads.add(thread);
configureThread(newListener, intraStages, stage, thread);
break;
}
case BY_SELF_DECISION: {
final RunnableProducerStage runnable = new RunnableProducerStage(stage);
final Thread thread = new Thread(runnable);
final Thread thread = createThread(newListener, intraStages, stage, runnable);
this.finiteProducerThreads.add(thread);
configureThread(newListener, intraStages, stage, thread);
break;
}
case BY_INTERRUPT: {
final RunnableProducerStage runnable = new RunnableProducerStage(stage);
final Thread thread = new Thread(runnable);
final Thread thread = createThread(newListener, intraStages, stage, runnable);
this.infiniteProducerThreads.add(thread);
configureThread(newListener, intraStages, stage, thread);
break;
}
default:
......@@ -166,7 +160,8 @@ public final class Analysis<T extends AnalysisConfiguration> implements Uncaught
}
private void configureThread(final AbstractExceptionListener newListener, final Set<Stage> intraStages, final Stage stage, final Thread thread) {
private Thread createThread(final AbstractExceptionListener newListener, final Set<Stage> intraStages, final Stage stage, final AbstractRunnableStage runnable) {
final Thread thread = new Thread(runnable);
stage.setExceptionHandler(newListener);
for (Stage intraStage : intraStages) {
intraStage.setOwningThread(thread);
......@@ -174,6 +169,7 @@ public final class Analysis<T extends AnalysisConfiguration> implements Uncaught
}
thread.setUncaughtExceptionHandler(this);
thread.setName(stage.getId());
return thread;
}
/**
......
wiki @ 162510ff
Subproject commit 0e4474577e1f49bc96e734c286b2d9e0363895e8
Subproject commit 162510ff4d2f04011498ba6920aae0c78347c6c8
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment