简体   繁体   中英

how to manage CPU resources

In a producing and consuming application, let's say producting takes one cpu cycle and consuming takes 3 avarage cpu cycles. Then how do we manage to keep equal number of productions and consumptions boundry. this is a problem I imaginge while I was studying threads.

If you have any idea to implement this with Java please share your knoweledge.

You have to design your system so that you consumers can keep up with your producer in the long run. Most producers are bursty and if you use a queue it doesn't matter that for very short periods they are producing faster than your can consume. If this is not the case you can

  • have multiple consumers.
  • drop or combine produced messages to reduce the load on the consumer.
  • push back on the producer to slow down.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM