![JAR search and dependency download from the Maven repository](/logo.png)
com.viaoa.concurrent.OAThread Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of oa-core Show documentation
Show all versions of oa-core Show documentation
Object Automation library
package com.viaoa.concurrent;
import com.viaoa.object.OAThreadLocalDelegate;
/**
* Allows a thread to have the same context as the thread that created it.
*
* @author vvia
*/
public class OAThread extends Thread {
private final Object context;
private Runnable runnable;
public OAThread(Runnable runnable) {
context = OAThreadLocalDelegate.getContext();
this.runnable = runnable;
}
@Override
public void run() {
if (context != null) {
OAThreadLocalDelegate.setContext(context);
}
runnable.run();
if (context != null) {
OAThreadLocalDelegate.setContext(null);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy