title: How can I solve MongoWaitQueueFullException?
body: <p>I run a java program which is a thread executor program that inserts thousands of documents to a table in mongodb. I get the following error</p>
  
  <pre><code>Exception in thread "pool-1-thread-301" com.mongodb.MongoWaitQueueFullException: Too many threads are already waiting for a connection. Max number of threads (maxWaitQueueSize) of 500 has been exceeded.
      at com.mongodb.PooledConnectionProvider.get(PooledConnectionProvider.java:70)
      at com.mongodb.DefaultServer.getConnection(DefaultServer.java:73)
      at com.mongodb.BaseCluster$WrappedServer.getConnection(BaseCluster.java:221)
      at com.mongodb.DBTCPConnector$MyPort.getConnection(DBTCPConnector.java:508)
      at com.mongodb.DBTCPConnector$MyPort.get(DBTCPConnector.java:456)
      at com.mongodb.DBTCPConnector.getPrimaryPort(DBTCPConnector.java:414)
      at com.mongodb.DBCollectionImpl.insert(DBCollectionImpl.java:176)
      at com.mongodb.DBCollectionImpl.insert(DBCollectionImpl.java:159)
      at com.mongodb.DBCollection.insert(DBCollection.java:93)
      at com.mongodb.DBCollection.insert(DBCollection.java:78)
      at com.mongodb.DBCollection.insert(DBCollection.java:120)
      at ScrapResults103$MyRunnable.run(MyProgram.java:368)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
      at java.lang.Thread.run(Thread.java:695)
  </code></pre>
  
  <p>How can I resolve this? Please help me. </p>