Code example for ReentrantLock

Methods: tryLock, unlock

0
 
		next.setOnClickListener(new View.OnClickListener() {
			@Override 
			public void onClick(View v)
			{ 
				if( regLock.tryLock() )
				{ 
					/*if(email.getText().toString().compareTo("") == 0 || pw.getText().toString().compareTo("") == 0) 
						Toast.makeText(ctx, "All fields are required", Toast.LENGTH_SHORT).show(); 
					else 
					{*/ 
						pb.setVisibility(View.VISIBLE); // show spinner
						regTask task = new regTask();
						task.execute(email.getText().toString(), fName.getText().toString(), lName.getText().toString(),
							city.getText().toString(), zip.getText().toString(), phone.getText().toString(), 
							bio.getText().toString(), pass.getText().toString(), cPass.getText().toString());
 
						try { 
							regLock.unlock();
						} catch (Exception e){
							Log.i(TAG, "ERROR: " +e.toString());
						} 
					//} 
					/* NOTE: it hides so quickly that it never actually