Skip to content

Commit

Permalink
F!! launch method on ThreadUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsEckart committed Sep 26, 2022
1 parent a335e18 commit 3c97c39
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Expand Up @@ -3,6 +3,8 @@
import com.spun.util.logger.SimpleLogger;
import org.lambda.actions.Action0;

import java.time.Duration;

public class LambdaThreadLauncher implements Runnable
{
private final Action0 function;
Expand All @@ -12,6 +14,9 @@ public LambdaThreadLauncher(Action0 function)
{
this(function, 0);
}
public LambdaThreadLauncher(Action0 function, Duration delay) {
this(function, delay.toMillis());
}
public LambdaThreadLauncher(Action0 function, long delay)
{
this.delay = delay;
Expand Down
12 changes: 12 additions & 0 deletions approvaltests-util/src/main/java/com/spun/util/ThreadUtils.java
@@ -1,5 +1,9 @@
package com.spun.util;

import org.lambda.actions.Action0;

import java.time.Duration;

public class ThreadUtils
{
public static void sleep(long millis)
Expand All @@ -13,6 +17,14 @@ public static void sleep(long millis)
// ignore
}
}
public static void launch(Action0 action)
{
launch(action, Duration.ZERO);
}
public static void launch(Action0 action, Duration delay)
{
new LambdaThreadLauncher(action, delay);
}
public static StackTraceElement[] getStackTrace()
{
return Thread.currentThread().getStackTrace();
Expand Down

0 comments on commit 3c97c39

Please sign in to comment.