How did the Java/C++ flow pool go?



  • The essence of the bullet is understandable, but there's no specific implementation. I am curious as to how the flow pool can reus flows if it worked with one task and adopted a new flow, but as far as I know the flow after the completion of the task cannot be reused, i.e. recycle Thread.start() cannot be used, the question is how the pool of flows saves the resources to create the flow if the flows cannot be reused and still needs to re-create the flow. Maybe I don't know anything or miss something, and I just don't know how to reverse the flow without getting Exception. I would also like to hear a C+++ opinion if there are differences with Java. Thank you.


  • QA Engineer

    Who told you the flow was coming to an end?

    If it's easier, the run-in in the bullets is endless, it's basically:

    while (true){
       // берётся задача из очереди и выполняется
       sleep(...);
    }
    

    Closer to reality is something:

    while (!pool.isShutdown()) {
        Runnable task = pool.waitForTaskOnQueue();  // ждём задачу
        task.run();  // выполняем
    }
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2