From c9d099c6943eb45216215c6a9708b35c2ac873f4 Mon Sep 17 00:00:00 2001 From: Redkale <8730487+redkale@users.noreply.github.com> Date: Thu, 20 Dec 2018 17:22:16 +0800 Subject: [PATCH] --- src/org/redkale/net/WorkThread.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/org/redkale/net/WorkThread.java b/src/org/redkale/net/WorkThread.java index 32eb3be3f..9781a24b4 100644 --- a/src/org/redkale/net/WorkThread.java +++ b/src/org/redkale/net/WorkThread.java @@ -17,6 +17,8 @@ import java.util.concurrent.*; */ public class WorkThread extends Thread { + protected Thread localThread; + private final ExecutorService executor; public WorkThread(ExecutorService executor, Runnable runner) { @@ -32,4 +34,19 @@ public class WorkThread extends Thread { public ExecutorService getExecutor() { return executor; } + + @Override + public void run() { + this.localThread = Thread.currentThread(); + super.run(); + } + + public boolean inSameThread() { + return this.localThread == Thread.currentThread(); + } + + public boolean inSameThread(Thread thread) { + return this.localThread == thread; + } + }