Code example for Thread

0
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.d(LOG_TAG, "onStartCommand");
        serverPort = Integer.parseInt(intent.getStringExtra("port"));
        openSocket(); 
 
        new Thread(new Runnable() {
            public void run() { 
                if(serverSocket != null) { 
                    try { 
                        String line = "";
                        while(true) { 
                            Socket newSocket = serverSocket.accept();
                            BufferedReader in = new BufferedReader(new InputStreamReader(newSocket.getInputStream()));
                            BufferedWriter out = new BufferedWriter(new OutputStreamWriter(newSocket.getOutputStream()));
                            line = in.readLine();
                            if(line.equals("androidFuzzerDead")) {
                                break; 
                            } 
                            Log.d(LOG_TAG,"read: "+line);
                            fuzzTable(line);
                            out.newLine();