THRIFT-2551 OutOfMemoryError "unable to create new native thread" kills serve thread

Github Pull Request: This closes #112

Patch: Fuud
diff --git a/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java b/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java
old mode 100644
new mode 100755
index 7229d89..488d17f
--- a/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java
+++ b/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java
@@ -139,6 +139,16 @@
               Thread.currentThread().interrupt();
               break;
             }
+          } catch(OutOfMemoryError ex) {
+            LOGGER.warn("ExecutorService throws OutOfMemoryError "+ ex.getMessage() + (++rejections) +
+                " times(s)", ex);
+            try {
+              TimeUnit.SECONDS.sleep(1);
+            } catch (InterruptedException e) {
+              LOGGER.warn("Interrupted while waiting to place client on executor queue.");
+              Thread.currentThread().interrupt();
+              break;
+            }
           }
         }
       } catch (TTransportException ttx) {