diff --git a/src/threads.c b/src/threads.c
index 6f927577cf665bab7933c7da8b89b58b85c46db6..1eca63737f65df8cdf6e4591d42d77ded2363b4a 100644
--- a/src/threads.c
+++ b/src/threads.c
@@ -1,5 +1,5 @@
 #include "global.h"
-RCSID("$Id: threads.c,v 1.67 1998/04/09 02:48:40 hubbe Exp $");
+RCSID("$Id: threads.c,v 1.68 1998/04/13 14:31:59 grubba Exp $");
 
 int num_threads = 1;
 int threads_disabled = 0;
@@ -159,12 +159,14 @@ struct thread_starter
 void exit_threads_disable(struct object *o)
 {
   if(threads_disabled) threads_disabled--;
+  /* fprintf(stderr, "exit_threads_disable(): threads_disabled:%d\n", threads_disabled); */
   co_broadcast(&threads_disabled_change);
 }
 
 void init_threads_disable(struct object *o)
 {
   threads_disabled++;
+  /* fprintf(stderr, "init_threads_disable(): threads_disabled:%d\n", threads_disabled); */
   while (live_threads) {
     THREADS_FPRINTF((stderr,
 		     "_disable_threads(): Waiting for %d threads to finish\n",
@@ -312,6 +314,11 @@ void *new_thread_func(void * data)
   thread_id=arg.id;
   SWAP_OUT_THREAD((struct thread_state *)thread_id->storage); /* Init struct */
   ((struct thread_state *)thread_id->storage)->swapped=0;
+#ifdef THREAD_TRACE
+  {
+    t_flag = default_t_flag;
+  }
+#endif /* THREAD_TRACE */
 
   THREADS_FPRINTF((stderr,"THREAD %08x INITED\n",(unsigned int)thread_id));
   if(SETJMP(back))
diff --git a/src/threads.h b/src/threads.h
index 09c0f258066ad5fd658d7b4bbb8d7ddce90c99a9..9242df2428eab361b52940851b0792e8ce1d0f11 100644
--- a/src/threads.h
+++ b/src/threads.h
@@ -1,5 +1,5 @@
 /*
- * $Id: threads.h,v 1.40 1998/03/28 14:58:31 grubba Exp $
+ * $Id: threads.h,v 1.41 1998/04/13 14:32:35 grubba Exp $
  */
 #ifndef THREADS_H
 #define THREADS_H
@@ -250,6 +250,9 @@ struct thread_state {
   int mark_stack_malloced;
   JMP_BUF *recoveries;
   struct object * thread_id;
+#ifdef THREAD_TRACE
+  int t_flag;
+#endif /* THREAD_TRACE */
 };
 
 #ifndef th_destroy
@@ -277,6 +280,14 @@ struct thread_state {
 #define THREADS_FPRINTF(X)	fprintf X
 #endif /* VERBOSE_THREADS_DEBUG */
 
+#ifdef THREAD_TRACE
+#define SWAP_OUT_TRACE(_tmp)	do { extern int t_flag; (_tmp)->t_flag = t_flag; } while(0)
+#define SWAP_IN_TRACE(_tmp)	do { extern int t_flag; t_flag = (_tmp)->t_flag; } while(0)
+#else /* !THREAD_TRACE */
+#define SWAP_OUT_TRACE(_tmp)
+#define SWAP_IN_TRACE(_tmp)
+#endif /* THREAD_TRACE */
+
 #define SWAP_OUT_THREAD(_tmp) do { \
        (_tmp)->swapped=1; \
        (_tmp)->evaluator_stack=evaluator_stack;\
@@ -288,6 +299,7 @@ struct thread_state {
        (_tmp)->recoveries=recoveries;\
        (_tmp)->sp=sp; \
        (_tmp)->thread_id=thread_id;\
+       SWAP_OUT_TRACE(_tmp); \
       } while(0)
 
 #define SWAP_IN_THREAD(_tmp) do {\
@@ -301,6 +313,7 @@ struct thread_state {
        recoveries=(_tmp)->recoveries;\
        sp=(_tmp)->sp;\
        thread_id=(_tmp)->thread_id;\
+       SWAP_IN_TRACE(_tmp); \
      } while(0)
 
 #define SWAP_OUT_CURRENT_THREAD() \