 	while (count < 100) {
 		old = atomicCAS((int *) &d_kernelWrapper->lock_thread_id, -1,
 				thread_id);
+
 		if (old == -1 || old == thread_id) {
 			//do critical section code
-
-			cuPrintf("Thread %d active_thread_id: %d\n", thread_id,
+			// thread won race condition
+
+			cuPrintf("Thread %d lock_thread_id: %d\n", thread_id,
 					d_kernelWrapper->lock_thread_id);
 
 			int val = d_kernelWrapper->getValue(thread_id);
+			cuPrintf("Thread %d getValue: %d\n", thread_id, val);
+
+			// exit infinite loop
+			break;
 
 		} else {
 			count++;

			}
		}
	}

	/*
	 bool accessed = false;


	// initialize cuPrintf
	cudaPrintfInit();

	device_method<<<1, 1>>>(d_kernelWrapper);

	// display the device's output
	cudaPrintfDisplay();
	// clean up after cuPrintf
	cudaPrintfEnd();

	// Send DONE to SocketServer
	h_kernelWrapper->lock_thread_id = 0;
	h_kernelWrapper->sendDone();

