Index: generic/tclBasic.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclBasic.c,v
retrieving revision 1.162
diff -u -r1.162 tclBasic.c
--- generic/tclBasic.c	21 Jun 2005 18:33:02 -0000	1.162
+++ generic/tclBasic.c	7 Jul 2005 16:06:35 -0000
@@ -701,19 +701,16 @@
     ClientData clientData;	/* One-word value to pass to proc. */
 {
     Interp *iPtr = (Interp *) interp;
-    static int assocDataCounter = 0;
-#ifdef TCL_THREADS
-    static Tcl_Mutex assocMutex;
-#endif
+    static Tcl_ThreadDataKey assocDataCounterKey;
+    int *assocDataCounterPtr =
+	    Tcl_GetThreadData(&assocDataCounterKey, (int)sizeof(int));
     int new;
     char buffer[32 + TCL_INTEGER_SPACE];
     AssocData *dPtr = (AssocData *) ckalloc(sizeof(AssocData));
     Tcl_HashEntry *hPtr;
 
-    Tcl_MutexLock(&assocMutex);
-    sprintf(buffer, "Assoc Data Key #%d", assocDataCounter);
-    assocDataCounter++;
-    Tcl_MutexUnlock(&assocMutex);
+    sprintf(buffer, "Assoc Data Key #%d", *assocDataCounterPtr);
+    (*assocDataCounterPtr)++;
 
     if (iPtr->assocData == (Tcl_HashTable *) NULL) {
 	iPtr->assocData = (Tcl_HashTable *) ckalloc(sizeof(Tcl_HashTable));
