@@ -117,7 +117,6 @@ public final class PythonContext {
117117 private volatile boolean finalizing ;
118118
119119 public static final class PythonThreadState {
120- private final WeakReference <Thread > owner ;
121120 private boolean shuttingDown = false ;
122121
123122 /*
@@ -138,7 +137,6 @@ public static final class PythonThreadState {
138137 HashSet <Object > reprObjectSet ;
139138
140139 public PythonThreadState (@ SuppressWarnings ("unused" ) PythonContext context , Thread owner ) {
141- this .owner = new WeakReference <>(owner );
142140 }
143141
144142 void shutdown () {
@@ -149,14 +147,6 @@ boolean isShuttingDown() {
149147 return shuttingDown ;
150148 }
151149
152- boolean isOwner (Thread thread ) {
153- return owner .get () == thread ;
154- }
155-
156- WeakReference <Thread > getOwner () {
157- return owner ;
158- }
159-
160150 @ TruffleBoundary
161151 boolean reprEnter (Object item ) {
162152 if (reprObjectSet == null ) {
@@ -1104,11 +1094,8 @@ public void popCurrentImport() {
11041094 public Thread [] getThreads () {
11051095 CompilerAsserts .neverPartOfCompilation ();
11061096 Set <Thread > threads = new HashSet <>();
1107- for (PythonThreadState ts : threadStateMapping .values ()) {
1108- Thread th = ts .getOwner ().get ();
1109- if (th != null ) {
1110- threads .add (th );
1111- }
1097+ for (Thread th : threadStateMapping .keySet ()) {
1098+ threads .add (th );
11121099 }
11131100 return threads .toArray (new Thread [0 ]);
11141101 }
@@ -1167,7 +1154,6 @@ public synchronized void disposeThread(Thread thread) {
11671154 // ts already removed, that is valid during context shutdown for daemon threads
11681155 return ;
11691156 }
1170- assert ts .isOwner (thread ) : "thread state owner was changed before this thread was disposed!" ;
11711157 ts .shutdown ();
11721158 threadStateMapping .remove (thread );
11731159 releaseSentinelLock (ts .sentinelLock );
0 commit comments