mirror of
https://github.com/corda/corda.git
synced 2025-02-15 07:02:24 +00:00
inherit thread locals at thread creation time, not start time
This commit is contained in:
parent
73155c6196
commit
da692a539f
@ -12,12 +12,6 @@ public class Thread implements Runnable {
|
|||||||
|
|
||||||
public Thread(Runnable task) {
|
public Thread(Runnable task) {
|
||||||
this.task = task;
|
this.task = task;
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void start() {
|
|
||||||
if (peer != 0) {
|
|
||||||
throw new IllegalStateException("thread already started");
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<ThreadLocal, Object> map = currentThread().locals;
|
Map<ThreadLocal, Object> map = currentThread().locals;
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
@ -28,11 +22,20 @@ public class Thread implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doStart();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void doStart();
|
public synchronized void start() {
|
||||||
|
if (peer != 0) {
|
||||||
|
throw new IllegalStateException("thread already started");
|
||||||
|
}
|
||||||
|
|
||||||
|
peer = doStart();
|
||||||
|
if (peer == 0) {
|
||||||
|
throw new RuntimeException("unable to start native thread");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private native long doStart();
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
if (task != null) {
|
if (task != null) {
|
||||||
|
@ -605,7 +605,7 @@ Thread_currentThread(Thread* t, jclass)
|
|||||||
return pushReference(t, t->javaThread);
|
return pushReference(t, t->javaThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
jlong
|
||||||
Thread_doStart(Thread* t, jobject this_)
|
Thread_doStart(Thread* t, jobject this_)
|
||||||
{
|
{
|
||||||
Thread* p = new (t->vm->system->allocate(sizeof(Thread)))
|
Thread* p = new (t->vm->system->allocate(sizeof(Thread)))
|
||||||
@ -613,15 +613,11 @@ Thread_doStart(Thread* t, jobject this_)
|
|||||||
|
|
||||||
enter(p, Thread::ActiveState);
|
enter(p, Thread::ActiveState);
|
||||||
|
|
||||||
threadPeer(t, *this_) = reinterpret_cast<jlong>(p);
|
if (t->vm->system->success(t->vm->system->start(&(p->runnable)))) {
|
||||||
|
return reinterpret_cast<jlong>(p);
|
||||||
if (not t->vm->system->success(t->vm->system->start(&(p->runnable)))) {
|
} else {
|
||||||
threadPeer(t, *this_) = -1;
|
|
||||||
|
|
||||||
p->exit();
|
p->exit();
|
||||||
|
return 0;
|
||||||
object message = makeString(t, "unable to start native thread");
|
|
||||||
t->exception = makeRuntimeException(t, message);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user