diff -u base/guicast/mutex.C hvirtual-1.1.6/guicast/mutex.C
--- base/guicast/mutex.C	2003-06-16 22:00:48.000000000 +0200
+++ hvirtual-1.1.6/guicast/mutex.C	2003-07-15 17:30:47.000000000 +0200
@@ -1,4 +1,5 @@
 #include "mutex.h"
+#include "thread.h"
 
 Mutex::Mutex()
 {
@@ -17,13 +18,23 @@
 	
 int Mutex::lock()
 {
-	if(pthread_mutex_lock(&mutex)) perror("Mutex::lock");
+	if(pthread_mutex_lock(&mutex)) {
+		perror("Mutex::lock");
+#ifdef DEBUG
+		printf("Thread id: %i,  name: %s\n", pthread_self(), get_thread_name());
+#endif
+	}
 	return 0;
 }
 
 int Mutex::unlock()
 {
-	if(pthread_mutex_unlock(&mutex)) perror("Mutex::unlock");
+	if(pthread_mutex_unlock(&mutex)) {
+		perror("Mutex::unlock");
+#ifdef DEBUG
+		printf("Thread id: %i,  name: %s\n", pthread_self(), get_thread_name());
+#endif
+	}
 	return 0;
 }
 
diff -u base/guicast/thread.C hvirtual-1.1.6/guicast/thread.C
--- base/guicast/thread.C	2003-06-16 22:01:12.000000000 +0200
+++ hvirtual-1.1.6/guicast/thread.C	2003-07-17 20:16:41.000000000 +0200
@@ -4,6 +4,49 @@
 #include <unistd.h>
 #include "thread.h"
 
+#ifdef DEBUG
+
+#include <typeinfo>
+#include <string.h>
+#include <mutex.h>
+
+	char thread_names[TMAX][64];
+	int thread_ids[TMAX];
+	int thread_count = 0;
+	Mutex tn_mutex;
+	char *get_thread_name()	
+	{
+		tn_mutex.lock();
+		int tid=pthread_self();
+		for (int i=0; i<thread_count; i++)
+			if (thread_ids[i]==tid)
+				return(thread_names[i]);
+		tn_mutex.unlock();
+	}
+	
+//void Thread::afterrun() {
+#define thread_afterrun \
+	{ \
+	tn_mutex.lock(); \
+	 \
+	int tid= pthread_self(); \
+	if (thread_count == 1) \
+		thread_count = 0; \
+	else { \
+		for (int i=0; i<thread_count; i++) \
+		{	\
+			if (thread_ids[i]== tid) { \
+				thread_ids[i]= thread_ids[thread_count-1]; \
+				strcpy(thread_names[i],thread_names[thread_count-1]); \
+ 				break; \
+			} \
+		} \
+		thread_count--; \
+	} \
+	tn_mutex.unlock(); \
+}
+
+#endif
 
 Thread::Thread(int synchronous, int realtime, int autodelete)
 {
@@ -26,16 +69,37 @@
 	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0);
 // Disable cancellation by default.
 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, 0);
-	
+
+#ifdef DEBUG
+	thread->prerun();
+#endif	
 
 	thread->run();
 
+#ifdef DEBUG
+	thread_afterrun;
+#endif	
+
 	thread->thread_running = 0;
 
 	if(thread->autodelete && !thread->synchronous) delete thread;
 	return NULL;
 }
 
+#ifdef DEBUG
+void Thread::prerun() {
+	tn_mutex.lock();
+
+	thread_ids[thread_count] = pthread_self(); 
+	strcpy (thread_names[thread_count],typeid(*this).name() ); 
+	thread_count ++;
+	tn_mutex.unlock();
+
+}
+
+
+#endif
+
 void Thread::start()
 {
 	pthread_attr_t  attr;
Only in hvirtual-1.1.6/guicast/: thread.C~
diff -u base/guicast/thread.h hvirtual-1.1.6/guicast/thread.h
--- base/guicast/thread.h	2003-06-16 22:00:48.000000000 +0200
+++ hvirtual-1.1.6/guicast/thread.h	2003-07-15 17:21:11.000000000 +0200
@@ -8,6 +8,18 @@
 // If it's synchronous the deletion occurs in join().
 // If it's asynchronous the deletion occurs in entrypoint.
 
+#define DEBUG
+
+#ifdef DEBUG
+	#define TMAX 255
+	extern char thread_names[TMAX][64];
+	extern int thread_ids[TMAX];
+	extern int thread_count;
+
+	char *get_thread_name(); // function that returns a pointer to the name of the object of the current thread
+
+#endif
+
 
 class Thread
 {
@@ -15,6 +27,10 @@
 	static void* entrypoint(void *parameters);
 protected:
 	virtual void run() = 0;
+#ifdef DEBUG
+	virtual void prerun();
+	virtual void afterrun();
+#endif
 public:
 	Thread(int synchronous = 0, int realtime = 0, int autodelete = 0);
 	virtual ~Thread();
