Index: configure.ac
===================================================================
--- configure.ac	(revision 37805)
+++ configure.ac	(working copy)
@@ -1779,7 +1779,29 @@
   [Says whether the objc_root_class attribute works])
 CFLAGS=$saved_CFLAGS
 
+
 #--------------------------------------------------------------------
+# Check if we can name pthreads
+#--------------------------------------------------------------------
+
+
+AC_CHECK_FUNC(pthread_setname_np, pthread_setname_ok=yes, pthread_setname_ok=no)
+if test $pthread_setname_ok = yes ; then
+	case "$target_os" in
+		darwin*)	AC_DEFINE(PTHREAD_SETNAME(a,b), pthread_setname_np(b),   [Description: Define set name function for pthread]);;
+		*)			AC_DEFINE(PTHREAD_SETNAME(a,b), pthread_setname_np(a,b), [Description: Define set name function for pthread]);;
+	esac
+fi
+
+AC_CHECK_FUNC(pthread_set_name_np, pthread_set_name_ok=yes, pthread_set_name_ok=no)
+if test $pthread_set_name_ok = yes ; then
+	AC_DEFINE(PTHREAD_SETNAME(a,b), pthread_set_name_np(a,b), [Description: Define set name function for pthread])
+fi
+
+
+
+
+#--------------------------------------------------------------------
 # Check whether Objective-C /really/ works
 #--------------------------------------------------------------------
 AC_MSG_CHECKING(whether objc really works)
Index: Headers/GNUstepBase/config.h.in
===================================================================
--- Headers/GNUstepBase/config.h.in	(revision 37805)
+++ Headers/GNUstepBase/config.h.in	(working copy)
@@ -872,3 +872,6 @@
 
 /* Define to `unsigned int' if <sys/types.h> does not define. */
 #undef size_t
+
+/* Define if using setname function of pthread */
+#undef PTHREAD_SETNAME
Index: Source/NSThread.m
===================================================================
--- Source/NSThread.m	(revision 37805)
+++ Source/NSThread.m	(working copy)
@@ -93,6 +93,47 @@
 #endif
 
 
+/* 
+ NSThread setName: method for windows 
+ */
+#if defined(__MINGW__) && defined(HAVE_WINDOWS_H)
+// Usage: SetThreadName (-1, "MainThread");
+#include <windows.h>
+const DWORD MS_VC_EXCEPTION=0x406D1388;
+
+#pragma pack(push,8)
+typedef struct tagTHREADNAME_INFO
+{
+	DWORD dwType; // Must be 0x1000.
+	LPCSTR szName; // Pointer to name (in user addr space).
+	DWORD dwThreadID; // Thread ID (-1=caller thread).
+	DWORD dwFlags; // Reserved for future use, must be zero.
+} THREADNAME_INFO;
+#pragma pack(pop)
+
+void SetThreadName( DWORD dwThreadID, char* threadName)
+{
+	THREADNAME_INFO info;
+	info.dwType = 0x1000;
+	info.szName = threadName;
+	info.dwThreadID = dwThreadID;
+	info.dwFlags = 0;
+	
+	__try
+	{
+		RaiseException( MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info );
+	}
+	__except(EXCEPTION_EXECUTE_HANDLER)
+	{
+	}
+}
+
+#define PTHREAD_SETNAME(a,b)  SetThreadName(-1, b)
+
+#endif
+
+
+
 // Some older BSD systems used a non-standard range of thread priorities.
 // Use these if they exist, otherwise define standard ones.
 #ifndef PTHREAD_MAX_PRIORITY
@@ -752,6 +793,9 @@
 - (void) setName: (NSString*)aName
 {
   ASSIGN(_name, aName);
+#ifdef PTHREAD_SETNAME
+	PTHREAD_SETNAME(pthread_self(), [aName cStringUsingEncoding:NSUTF8StringEncoding]);
+#endif
 }
 
 - (void) setStackSize: (NSUInteger)stackSize
