 		cuPrintf("getValue lock_thread_id: %d result_available: %s\n",
 				lock_thread_id, (result_available) ? "true" : "false");
 
-		lock_thread_id = -1;
+		//lock_thread_id = -1;
 		//__threadfence_system();
 		__threadfence();
 		return result_int;

	// lock_thread_id was already set
	__device__ int getValue(int val) {

		while (has_task) {
		}
		cuPrintf("getValue lock_thread_id: %d val: %d\n", lock_thread_id, val);


			//do critical section code
			// thread won race condition

			cuPrintf("Thread %d GOT LOCK 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);

			d_kernelWrapper->lock_thread_id = -1;
			//atomicExch((int *) &d_kernelWrapper, -1);
			//__threadfence_system();
			__threadfence();

			// exit infinite loop
			break;
