01: package org.python.core;
02:
03: class ThreadStateMapping2 extends ThreadStateMapping {
04: private static ThreadLocal cachedThreadState = new ThreadLocal();
05:
06: public ThreadState getThreadState(PySystemState newSystemState) {
07: ThreadState ts = (ThreadState) cachedThreadState.get();
08: if (ts != null) {
09: return ts;
10: }
11:
12: Thread t = Thread.currentThread();
13:
14: if (newSystemState == null) {
15: Py.writeDebug("threadstate", "no current system state");
16: // t.dumpStack();
17: newSystemState = Py.defaultSystemState;
18: }
19:
20: ts = new ThreadState(t, newSystemState);
21: cachedThreadState.set(ts);
22: return ts;
23: }
24: }
|