Deadlock in ThreadPoolExecutor

前端 未结 6 1899
温柔的废话
温柔的废话 2020-12-24 15:44

Encountered a situation when ThreadPoolExecutor is parked in execute(Runnable) function while all the ThreadPool threads are waiting i

6条回答
  •  盖世英雄少女心
    2020-12-24 16:06

    Definitely strange.

    But before writing your own TPE try:

    • another BlockingQueue impl., e.g. LinkedBlockingQueue

    • specify fairness=true in ArrayBlockingQueue, i.e. use new ArrayBlockingQueue(n, true)

    From those two opts I would chose second one 'cause it's very strange that offer() being blocked; one reason that comes into mind - thread scheduling policy on your Linux. Just as an assumption.

提交回复
热议问题