Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8680937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:22:37+00:00 2026-06-12T21:22:37+00:00

Ok this could be a very big question. I have one service(say notifier) and

  • 0

Ok this could be a very big question.

I have one service(say notifier) and one of method [say notifyTransaction(Transaction trans) ] of this service is remotely available for callbacks.

Now there is other service say (transactionsReader) which keeps reading incoming transactions and calls up the remote method of notifier that is notifyTransaction(Transaction trans).

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 processOperation(Operation op).

This processOperation(Operation op) actually do some updates on a database.

Whats the problem ?
The service transactionsReader is reading incoming transactions at very fast speed and calling up the notifyTransactions() at the speed much greater than the speed of processing operations by processOperation(Operation op) method.

What I want to do ?
I want to use multithreadint in notifyTransactions() so that I have multiple threads to treat every transaction.

For starting I used
ExecutorService executor = Executors.newFixedThreadPool(2);
in the method notifyTransactions() and created task of my method processOperation(Operation op). But this creates a different pool for every call to notifyTransactions() so I had somewhere around 3000 pools in few seconds. And finally it went Out of Memory.

What could be other possible solutions ?

Thanks in advance 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T21:22:38+00:00Added an answer on June 12, 2026 at 9:22 pm

    For starting I used ExecutorService executor = Executors.newFixedThreadPool(2); in the method notifyTransactions()

    This is the issue you need ExecutorService instance to be common in both. If you start invoking per operation then it will create large number of threads. You should just call submit task inside notifyTransactions()

    You should use a producer consumer approach using BlockingQueue which is bounded. So if queue is full producer will stop if queue is empty consumers will stop.
    So in your case processOperation(Operation op) is a producer which will process operation and put it in BlockingQueue and inside notifyTransactions() you will dequeue it and process accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think this could be a very easy question for you. But I have
First of all, I want to say sorry for this very big question, but
Introduction: Now I know this question could be very broad and it would be
I would be very grateful if someone could help me with this. I have
This could be considered a duplicate question, as a similar one has already been
A VERY nice to have would be if I could edit object-literals in this
I have two controls. The XAML's are big and very similar. One difference is
It could very well be that the answer to this question is an obvious
This could be a very basic Javascript I know but I just can't get
This looked like a very simple question but I couldn't find the answer. How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.