Code example for ReentrantLock

Methods: tryLock, unlock

0
		pb = (ProgressBar)findViewById(R.id.login_progress);
		login.setOnClickListener(new View.OnClickListener() {
			@Override 
			public void onClick(View v)
			{ 
				if( loginLock.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
						loginTask task = new loginTask();
						task.execute(email.getText().toString(), pw.getText().toString());
 
						try { 
							loginLock.unlock();
						} catch (Exception e){
							Log.i(TAG, "ERROR: " +e.toString());
						} 
					} 
					/* NOTE: it hides so quickly that it never actually