We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Q. ThreadPool은 thread에게 어떻게 작업을 배분하는가?
The text was updated successfully, but these errors were encountered:
쓰레드풀이 어떻게 쓰레드에게 작업을 할당 해주는지 찾아보았습니다..! 결론은 쓰레드풀이 알아서 잘 업무를 할당해주고 있었는데요..!
현재 일하고 있는 쓰레드와 할당된 쓰레드의 갯수를 비교하여 풀의 사이즈를 넘지 않으면 쓰레드를 가져와 업무를 배분하고, 아니면 workQueue 에 집어넣고 다른 쓰레드가 일이 끝날때까지 기다립니다. 그 후 쓰레드가 일이 끝나면 업무를 배분합니다.
public void execute(Runnable command) { if (command == null) throw new NullPointerException(); int c = ctl.get(); if (workerCountOf(c) < corePoolSize) { if (addWorker(command, true)) return; c = ctl.get(); } if (isRunning(c) && workQueue.offer(command)) { int recheck = ctl.get(); if (! isRunning(recheck) && remove(command)) reject(command); else if (workerCountOf(recheck) == 0) addWorker(null, false); } else if (!addWorker(command, false)) reject(command); }
참고해서 보면 좋을 다른 메서드들 boolean addWorker(Runnable firstTask, boolean core), void runWorker(Worker w)
boolean addWorker(Runnable firstTask, boolean core)
void runWorker(Worker w)
Sorry, something went wrong.
No branches or pull requests
Q. ThreadPool은 thread에게 어떻게 작업을 배분하는가?
The text was updated successfully, but these errors were encountered: