title: Android Null Pointer Exception Thread Issue
body: <p>Hey guys I'm running this code in Android:</p>
  
  <pre><code>public ServiceServer(String serverName) {
      this.serverName = serverName;
      this.serverThread = new Thread() {
          public void run() {
              serverThreadProc();
          }
      };
  }
  
  private void serverThreadProc() {
      while (!this.stopRequested) {
          Socket sessionSocket = null;
          try {
              sessionSocket = this.serverSocket.accept();
              InetAddress sourceAddress = sessionSocket.getInetAddress();
              Log.i(LOG_TAG, "Accepted new incoming connection ... "
                      + sourceAddress.toString());
              if (clientMap.containsKey(sourceAddress)) {
                  ClientProcessor legacyProcessor = clientMap
                          .get(sourceAddress);
                  legacyProcessor.shutdown();
              }
              ClientProcessor processor = new ClientProcessor(sessionSocket);
              processor.start();
              clientMap.put(sourceAddress, processor);
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
      }
  }
  
  public int start() {
  
      try {
          this.serverSocket = new ServerSocket(0);
          this.serverPort = this.serverSocket.getLocalPort();
          Log.i(LOG_TAG, "Server " + serverName + " started at "
                  + this.serverSocket.getLocalSocketAddress());
      } catch (IOException ex) {
          Log.i(LOG_TAG, ex.toString());
      }
  
      this.serverThread.start();
  
      return this.serverPort;
  }
  
  public void stop() {
      try {
          stopRequested = true;
          if (null != this.serverSocket) {
              this.serverSocket.close();
          }
      } catch (IOException ex) {
          Log.i(LOG_TAG, ex.toString());
      }
  
      Log.i(LOG_TAG, "The server " + this.serverName + " has been stopped.");
  }
  </code></pre>
  
  <p>and I'm getting a null pointer exception error that has something to do with my thread?  For some reason it gets hung up on the serverThreadProc() method.  Here is the stack trace I'm getting from the issue:</p>
  
  <pre><code>01-10 02:10:13.361: I/ActivityThread(2216): Pub com.whooznear.android: com.whooznear.android.ProfileProvider
  01-10 02:10:13.642: D/dalvikvm(2216): GC_FOR_ALLOC freed 44K, 4% free 6336K/6595K, paused 95ms
  01-10 02:10:13.662: I/dalvikvm-heap(2216): Grow heap (frag case) to 6.805MB for 588816-byte allocation
  01-10 02:10:13.801: D/dalvikvm(2216): GC_FOR_ALLOC freed 8K, 4% free 6903K/7175K, paused 109ms
  01-10 02:10:14.051: D/dalvikvm(2216): GC_CONCURRENT freed &lt;1K, 4% free 6903K/7175K, paused 8ms+15ms
  01-10 02:10:17.462: D/dalvikvm(2216): GC_FOR_ALLOC freed 603K, 11% free 6666K/7431K, paused 81ms
  01-10 02:10:17.622: D/dalvikvm(2216): GC_CONCURRENT freed &lt;1K, 4% free 7167K/7431K, paused 5ms+13ms
  01-10 02:10:17.971: W/Profile(2216): Invalid profile, java.lang.ArrayIndexOutOfBoundsException: index=1 length=1
  01-10 02:10:31.801: I/ConnectActivity(2216): IP Address:0
  01-10 02:10:31.812: I/ServiceServer(2216): java.net.SocketException: Permission denied
  01-10 02:10:31.812: I/ConnectActivity(2216): Started at -1
  01-10 02:10:31.861: W/dalvikvm(2216): threadid=9: thread exiting with uncaught     exception (group=0x40014760)
  01-10 02:10:31.861: E/AndroidRuntime(2216): FATAL EXCEPTION: Thread-12
  01-10 02:10:31.861: E/AndroidRuntime(2216): java.lang.NullPointerException
  01-10 02:10:31.861: E/AndroidRuntime(2216):     at com.whooznear.android.ServiceServer.serverThreadProc(ServiceServer.java:61)
  01-10 02:10:31.861: E/AndroidRuntime(2216):     at com.whooznear.android.ServiceServer.access$0(ServiceServer.java:57)
  01-10 02:10:31.861: E/AndroidRuntime(2216):     at com.whooznear.android.ServiceServer$1.run(ServiceServer.java:52)
  01-10 02:10:32.301: D/dalvikvm(2216): GC_CONCURRENT freed 397K, 7% free 7187K/7687K, paused 9ms+11ms
  01-10 02:10:34.761: I/Process(2216): Sending signal. PID: 2216 SIG: 9
  </code></pre>