@Override
	public void lock(int thread_id)
	{
		choosing_[thread_id] = true;
		choosing_ = choosing_; //force the other threads to see that choosing_[thread_id] has updated
		number_[thread_id] = max() + 1;
		choosing_[thread_id] = false;
		choosing_ = choosing_; //force the other threads to see that choosing_[thread_id] and number_[thread_id] have updated
		
		for (int i = 0; i < number_.length; i++)
		{
			//don't make the thread wait on itself
			if (i == thread_id)
			{
				continue;
			}

			//make sure the thread isn't choosing its ticket
			while (choosing_[i]) {};
			//then wait for the other thread to not be waiting and/or finish in the critical section
			while (!((number_[i] == 0) || ((number_[thread_id] < number_[i]) || ((number_[thread_id] == number_[i]) && (thread_id < i))))) {};
		}
	}