--- configure.in.old	Mon Jan 19 00:31:09 2009
+++ configure.in	Sun Jul 12 13:08:57 2009
@@ -862,17 +862,21 @@
     echo Disabling multithreaded support
 else
     echo Enabling multithreaded support
-
-    AC_CHECK_HEADER(pthread.h,
-	AC_CHECK_LIB(pthread, pthread_join,[
-	   THREAD_LIBS="-lpthread"
-	   AC_DEFINE([HAVE_LIBPTHREAD], [], [Define if pthread library is there (-lpthread)])
-	   AC_DEFINE([HAVE_PTHREAD_H], [], [Define if <pthread.h> is there])
-	   WITH_THREADS="1"]))
+    dnl Use pthread by default
+    if test "$with_threads" = "pthread" | test "$with_threads" = "" ; then
+        AC_CHECK_HEADER(pthread.h,
+    	    AC_CHECK_LIB(pthread, pthread_join,[
+	       THREAD_LIBS="-lpthread"
+	       AC_DEFINE([HAVE_LIBPTHREAD], [], [Define if pthread library is there (-lpthread)])
+	       AC_DEFINE([HAVE_PTHREAD_H], [], [Define if <pthread.h> is there])
+	       WITH_THREADS="1"]))
+    fi
     case $host_os in
-       *mingw32*) WITH_THREADS="1"
-           THREADS_W32="Win32"
-	   THREAD_CFLAGS="$THREAD_CFLAGS -DHAVE_WIN32_THREADS"
+       *mingw32*) if test "$THREAD_LIBS" != "-lpthread"; then
+               WITH_THREADS="1"
+               THREADS_W32="Win32"
+	       THREAD_CFLAGS="$THREAD_CFLAGS -DHAVE_WIN32_THREADS"
+           fi
        ;;
        *cygwin*) THREAD_LIBS=""
        ;;
