1 2 package org.python.core; 3 4 class ThreadStateMapping2 extends ThreadStateMapping { 5 private static ThreadLocal cachedThreadState = new ThreadLocal (); 6 7 public ThreadState getThreadState(PySystemState newSystemState) { 8 ThreadState ts = (ThreadState)cachedThreadState.get(); 9 if (ts != null) { 10 return ts; 11 } 12 13 Thread t = Thread.currentThread(); 14 15 if (newSystemState == null) { 16 Py.writeDebug("threadstate", "no current system state"); 17 newSystemState = Py.defaultSystemState; 19 } 20 21 ts = new ThreadState(t, newSystemState); 22 cachedThreadState.set(ts); 23 return ts; 24 } 25 } 26 | Popular Tags |