title: putting thread to sleep with Long.MAX_VALUE
body: <p>I wrote a program which is running at a server and listening on some ports. Since most of the time it has nothing to do, I set up a thread which prevents the program from stopping.</p>
  
  <p>My solution looks like the following:</p>
  
  <pre><code>Thread mainThread = new Thread( new Runnable() {
  
              @Override
              public void run() {
  
                  // run program continuously
                  while ( true ) {
                      try {
                          // since we aren't doing anything, the thread can sleep
                          Thread.sleep( Long.MAX_VALUE );
                      }
                      catch ( InterruptedException e ) {
  
                          e.printStackTrace();
                      }
                  }
              }
          } );
  
          mainThread.start();
  </code></pre>
  
  <p>My question is: 
  Could the constant <strong>Long.MAX_VALUE</strong> be problematic and cause an error? I want to run the program all the time, so in my opinion the thread does not need to do anything. The easiest solution so far, is to put it to (very, very deep) sleep (the milisecond value translates roughly to 146.235.600 years). </p>