title: Multithreading while call-back to a function
body: <p>Ok this could be a very big question.</p>
  
  <p>I have one service(say notifier) and one of method [say notifyTransaction(Transaction trans) ] of this service  is remotely available for callbacks.</p>
  
  <p>Now there is other service say (transactionsReader) which keeps reading incoming transactions and calls up the remote method of notifier that is <code>notifyTransaction(Transaction trans).</code></p>
  
  <p>Now to explain you the problem, I would like to add that my transaction contains more than one Operations. And for treating operations i have one function say <code>processOperation(Operation op).</code> </p>
  
  <p>This <code>processOperation(Operation op)</code> actually do some updates on a database.</p>
  
  <p>Whats the problem ?
    The service transactionsReader is reading incoming transactions at very fast speed and calling up the <code>notifyTransactions()</code> at the speed much greater than the speed of processing operations by <code>processOperation(Operation op)</code> method.</p>
  
  <p>What I want to do ?
   I want to use multithreadint in <code>notifyTransactions()</code> so that I have multiple threads to treat every transaction.</p>
  
  <p>For starting I used 
  <code>ExecutorService executor = Executors.newFixedThreadPool(2);</code>
  in the method <code>notifyTransactions()</code> and created task of my method processOperation(Operation op). But this creates a different pool for every call to <code>notifyTransactions()</code> so I had somewhere around 3000 pools in few seconds. And finally it went Out of Memory.</p>
  
  <p>What could be other possible solutions ?</p>
  
  <p>Thanks in advance :)</p>