src/org/jnetpcap/PcapUtils.java
public static <T> PcapTask<T> dispatchInBackground(
	    Pcap pcap,
	    int cnt,
	    final JBufferHandler<T> handler,
	    final T data) {

		return new PcapTask<T>(pcap, cnt, data) {

			public void run() {
				int remaining = count;

				while (remaining > 0) {

					/*
					 * Yield to other threads on every iteration of the loop, another
					 * words everytime the libpcap buffer has been completely filled.
					 * Except on the first loop, we don't want to yield but go right into
					 * the dispatch loop. Also having the yield at the top allows the
					 * thread to exit when total count packets have been dispatched and
					 * thus avoid an extra explicit yied, but achive implicit yield
					 * because this thread will terminate.
					 */
					if (remaining != 0) {
						Thread.yield();
					}

					this.result = this.pcap.dispatch(count, handler, data);

					/*
					 * Check for errors
					 */
					if (result < 0) {
						break;
					}

					/*
					 * If not an error, result contains number of packets dispatched or
					 * how many packets fit into the libpcap buffer
					 */
					remaining -= result;
				}
			}
		};
	}
/**
	 * Runs the dispatch function in a background thread. The function returns
	 * immediately and returns a PcapTask from which the user can interact with
	 * the background task.
	 * 
	 * @param <T>
	 *          user supplied type
	 * @param pcap
	 *          an open pcap object
	 * @param cnt
	 *          number of packets to capture and exit, 0 for infinate
	 * @param handler
	 *          user supplied callback handler
	 * @param data
	 *          opaque, user supplied data object dispatched back to the handler
	 * @return a task object which allows interaction with the underlying capture
	 *         loop and thread
	 */
Runs the dispatch function in a background thread. The function returns
immediately and returns a PcapTask from which the user can interact with
the background task.


Runs the dispatch function in a background thread . The function returns immediately and returns a PcapTask from which the user can interact with the background task .
public static <T> PcapTask<T> dispatchInBackground(
	    Pcap pcap,
	    int cnt,
	    final JBufferHandler<T> handler,
	    final T data) {
		return new PcapTask<T>(pcap, cnt, data) {
			public void run() {
				int remaining = count;
				while (remaining > 0) {
					/*
					 * Yield to other threads on every iteration of the loop, another
					 * words everytime the libpcap buffer has been completely filled.
					 * Except on the first loop, we don't want to yield but go right into
					 * the dispatch loop. Also having the yield at the top allows the
					 * thread to exit when total count packets have been dispatched and
					 * thus avoid an extra explicit yied, but achive implicit yield
					 * because this thread will terminate.
					 */
					if (remaining != 0) {
						Thread.yield();
					}
					this.result = this.pcap.dispatch(count, handler, data);
					/*
					 * Check for errors
					 */
					if (result < 0) {
						break;
					}
					/*
					 * If not an error, result contains number of packets dispatched or
					 * how many packets fit into the libpcap buffer
					 */
					remaining -= result;
				}
			}
		};
	}
public static < T > PcapTask < T > dispatchInBackground ( Pcap pcap , int cnt , final JBufferHandler < T > handler , final T data ) { return new PcapTask < T > ( pcap , cnt , data ) { public void run ( ) { int remaining = count ; while ( remaining > 0 ) { /*
					 * Yield to other threads on every iteration of the loop, another
					 * words everytime the libpcap buffer has been completely filled.
					 * Except on the first loop, we don't want to yield but go right into
					 * the dispatch loop. Also having the yield at the top allows the
					 * thread to exit when total count packets have been dispatched and
					 * thus avoid an extra explicit yied, but achive implicit yield
					 * because this thread will terminate.
					 */ if ( remaining != 0 ) { Thread . yield ( ) ; } this . result = this . pcap . dispatch ( count , handler , data ) ; /*
					 * Check for errors
					 */ if ( result < 0 ) { break ; } /*
					 * If not an error, result contains number of packets dispatched or
					 * how many packets fit into the libpcap buffer
					 */ remaining -= result ; } } } ; }
Runs the dispatch function in a background thread.
Runs the dispatch function in a background thread .