 			int val = d_kernelWrapper->getValue(thread_id);
 			cuPrintf("Thread %d getValue: %d\n", thread_id, val);
 
+			d_kernelWrapper->lock_thread_id = -1;
+			__threadfence();
 			// exit infinite loop
 			break;
 

		int old = atomicCAS((int *) &d_kernelWrapper->lock_thread_id, -1,
				thread_id);

		//cuPrintf("Thread %d old: %d\n", thread_id, old);

		if (old == -1 || old == thread_id) {
			//do critical section code

				_this->reset();
				pthread_mutex_unlock(lock);
				printf(
						"KernelWrapper thread: %p, UNLOCKED(mutex_process_command)\n",
						pthread_self());

			}
		}
