package com.xbtunnel; import java.util.HashSet; import java.util.Set; import java.util.prefs.Preferences; import jpcap.JpcapCaptor; import jpcap.PacketReceiver; import jpcap.packet.EthernetPacket; import jpcap.packet.Packet; class testcase { private static boolean isSearching = true; private static JpcapCaptor xboxFinder = null; private static Thread detectionThread; public static void startFindXboxes(jpcap.NetworkInterface device) throws Exception { //xboxFinder = JpcapCaptor.openDevice(device, 2000, false, 5); //xboxFinder.setFilter("udp && host 0.0.0.1", false); //xboxFinder.processPacket(1, handler); System.out.println("Beginning to detect xboxes. Please press any key to stop searching for xboxes!"); startDetectionThread(); Thread.sleep(3000); System.out.println("setting it to false"); isSearching = false; System.out.println("its false"); } public static void startDetectionThread() { if(detectionThread != null) { return; } detectionThread = new Thread(new Runnable() { public void run() { while(detectionThread != null) { //if(xboxFinder.processPacket(-1, handler) == 0 && !isLiveCapture) { if(!isSearching) { stopDetectionThread(); } Thread.yield(); } //System.out.println("thread exit"); xboxFinder.breakLoop(); } }); detectionThread.start(); } public static void stopDetectionThread() { detectionThread = null; } public static void main() { startFindXboxes(); } }