src/com/shrewdify/diaroser/impl/PeerImpl.java
@Override
		public void run() {
			while(true){
				byte b[]=null;
				boolean loc=false;
				if(requestQueue.size()>Constants.ZERO){
					try{
						loc=requestQueue.getLock();
						if(loc)
							b=requestQueue.remove();
					}
					catch(Exception e){
						b=null;
					}
					finally{
						if(loc)
							requestQueue.lock.unlock();
					}
					if(b!=null){
						try {
							b=processBillingRequest(b);
						} catch (IOException e1) {
							e1.printStackTrace();
						} catch (NoSpaceException e1) {
							e1.printStackTrace();
						} catch (SQLException e1){
							e1.printStackTrace();
						}catch (ArithmeticException e1){
							e1.printStackTrace();
							try {
								s.close();
							} catch (IOException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}
						
						}

						if(b!=null){
							try{
								//	System.out.println("Added Response:"+(k1++));
								loc=responseQueue.getLock();
								while(!loc){
									loc=responseQueue.getLock();
									delay(1);
								}
								if(loc)
									responseQueue.add(b);
							}
							catch(Exception e){
								e.printStackTrace();
							}
							finally{
								if(loc){
									responseQueue.lock.unlock();
									delay(1);
								}
							}
							log.debug("Processed a packet from queue");
						}
					}
				}else
					delay(1);
			}

		}
/**
		 * It starts a thread which continuously checks for the queue size, 
		 * if queue contains some request it tries to acquire lock on it removes 
		 * the request from queue and release the lock and process the requests.  
		 */
It starts a thread which continuously checks for the queue size,
if queue contains some request it tries to acquire lock on it removes
the request from queue and release the lock and process the requests.
It starts a thread which continuously checks for the queue size if queue contains some request it tries to acquire lock on it removes the request from queue and release the lock and process the requests .
@Override
		public void run() {
			while(true){
				byte b[]=null;
				boolean loc=false;
				if(requestQueue.size()>Constants.ZERO){
					try{
						loc=requestQueue.getLock();
						if(loc)
							b=requestQueue.remove();
					}
					catch(Exception e){
						b=null;
					}
					finally{
						if(loc)
							requestQueue.lock.unlock();
					}
					if(b!=null){
						try {
							b=processBillingRequest(b);
						} catch (IOException e1) {
							e1.printStackTrace();
						} catch (NoSpaceException e1) {
							e1.printStackTrace();
						} catch (SQLException e1){
							e1.printStackTrace();
						}catch (ArithmeticException e1){
							e1.printStackTrace();
							try {
								s.close();
							} catch (IOException e) {
								e.printStackTrace();
							}
						}
						if(b!=null){
							try{
								loc=responseQueue.getLock();
								while(!loc){
									loc=responseQueue.getLock();
									delay(1);
								}
								if(loc)
									responseQueue.add(b);
							}
							catch(Exception e){
								e.printStackTrace();
							}
							finally{
								if(loc){
									responseQueue.lock.unlock();
									delay(1);
								}
							}
							log.debug("Processed a packet from queue");
						}
					}
				}else
					delay(1);
			}
		}
@ Override public void run ( ) { while ( true ) { byte b [ ] = null ; boolean loc = false ; if ( requestQueue . size ( ) > Constants . ZERO ) { try { loc = requestQueue . getLock ( ) ; if ( loc ) b = requestQueue . remove ( ) ; } catch ( Exception e ) { b = null ; } finally { if ( loc ) requestQueue . lock . unlock ( ) ; } if ( b != null ) { try { b = processBillingRequest ( b ) ; } catch ( IOException e1 ) { e1 . printStackTrace ( ) ; } catch ( NoSpaceException e1 ) { e1 . printStackTrace ( ) ; } catch ( SQLException e1 ) { e1 . printStackTrace ( ) ; } catch ( ArithmeticException e1 ) { e1 . printStackTrace ( ) ; try { s . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } if ( b != null ) { try { loc = responseQueue . getLock ( ) ; while ( ! loc ) { loc = responseQueue . getLock ( ) ; delay ( 1 ) ; } if ( loc ) responseQueue . add ( b ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } finally { if ( loc ) { responseQueue . lock . unlock ( ) ; delay ( 1 ) ; } } log . debug ( "Processed a packet from queue" ) ; } } } else delay ( 1 ) ; } }
It starts a thread which continuously checks for the queue size,
 if queue contains some request it tries to acquire lock on it removes
 the request from queue and release the lock and process the requests.
It starts a thread which continuously checks for the queue size if queue contains some request it tries to acquire lock on it removes the request from queue and release the lock and process the requests .
// TODO Auto-generated catch block //	System.out.println("Added Response:"+(k1++));