{"id":348058,"date":"2023-05-29T21:06:04","date_gmt":"2023-05-29T21:06:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=348058"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=348058","title":{"rendered":"<span>\u041c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0438 Thread Pool \u0432 C++<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u042f \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e \u0441\u043e\u0437\u0440\u0435\u043b \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0442\u0443\u0442. \u0417\u0430 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0432 \u0441\u0444\u0435\u0440\u0435 IT \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0441\u0432\u043e\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 C++, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e, \u043d\u043e \u0432\u0435\u0440\u043d\u043e \u043e\u0431\u0440\u0430\u0441\u0442\u0430\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c\u0438 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438. \u041d\u0435 \u0432\u0441\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0435 \u0432 \u043d\u0435\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u043c\u043d\u043e\u044e \u0441 \u043d\u0443\u043b\u044f, \u043d\u043e \u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u0442\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043f\u043e\u0434 \u0441\u0432\u043e\u0438 \u043d\u0443\u0436\u0434\u044b. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u043d\u0435\u043f\u0440\u0435\u043e\u0434\u043e\u043b\u0438\u043c\u043e\u0435 \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043c\u043e\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438.<\/p>\n<h2>\u041e \u0447\u0435\u043c \u0438 \u0437\u0430\u0447\u0435\u043c \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f?<\/h2>\n<p>\u042f \u0434\u0430\u0432\u043d\u043e \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u0441\u044f \u0442\u0435\u043c\u043e\u0439 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u043d\u0435\u0439 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u043c\u043e\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445. \u042f \u043d\u0438 \u0432 \u043a\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u044e \u043d\u0430 \u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u0430 \u0432 \u044d\u0442\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438, \u043b\u0438\u0448\u044c \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u044f \u0431\u0443\u0434\u0443 \u0433\u0434\u0435-\u0442\u043e \u043d\u0435\u0442\u043e\u0447\u0435\u043d, \u0442\u043e \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u043d\u044f\u0442\u044c, \u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c. \u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u0433\u0440\u0430\u043c\u043e\u0442\u043d\u043e \u0438 \u0434\u043e\u0445\u043e\u0434\u0447\u0438\u0432\u043e \u043e\u0441\u0432\u0435\u0442\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b:<\/p>\n<ol>\n<li>\n<p>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u0438 \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f?<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043d\u044f\u0442\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0438 \u043f\u043e\u0442\u043e\u043a\u0430 \u0432 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u041a\u0430\u043a \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043c\u0430\u0448\u0438\u043d\u0430?<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043d\u044f\u0442\u0438\u0435 \u043f\u0443\u043b\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 C++.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432 C++.<\/p>\n<\/li>\n<li>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0443\u043b\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 C++.<\/p>\n<\/li>\n<\/ol>\n<p>\u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e, \u0438\u0437\u0443\u0447\u0430\u044f \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c, \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c &#171;\u043e\u0431\u043b\u0430\u0437\u0438\u0442\u044c&#187; \u043a\u0443\u0447\u0443 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0434\u0435\u0441\u044c \u044f \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b \u043f\u0435\u0440\u0435\u0434 \u0441\u043e\u0431\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0443 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u043e\u0435\u0434\u0438\u043d\u043e. \u042f \u043e\u0447\u0435\u043d\u044c \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f, \u0438 \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442 \u043a\u043e\u043c\u0443-\u043d\u0438\u0431\u0443\u0434\u044c \u0436\u0438\u0437\u043d\u044c.<\/p>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0435?<\/h2>\n<p><strong>\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f<\/strong>&nbsp;\u2014 \u044d\u0442\u043e \u0442\u0438\u043f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e&nbsp;\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0438\u043b\u0438&nbsp;\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432. \u0411\u043e\u043b\u044c\u0448\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0447\u0430\u0441\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043c\u0435\u043b\u043a\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0442\u0435\u043c \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u044b \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u0438, \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0448\u0435\u043d\u0430 \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435.<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043e \u0447\u0435\u043c \u0438\u0434\u0435\u0442 \u0440\u0435\u0447\u044c, \u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043a\u0430\u043b\u0430\u043c\u0431\u0443\u0440\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 \u043f\u043e\u0432\u0441\u0435\u0434\u043d\u0435\u0432\u043d\u043e\u0439 \u0436\u0438\u0437\u043d\u0438.<\/p>\n<blockquote>\n<p><em>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0441\u0435\u0431\u044f \u0432&nbsp;\u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u043e\u043c \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0435, \u0441&nbsp;\u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0439 \u0442\u0435\u043b\u0435\u0436\u043a\u043e\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432, \u0441\u0442\u043e\u044f\u0449\u0435\u0433\u043e \u0432&nbsp;\u043d\u0435&nbsp;\u043c\u0435\u043d\u0435\u0435 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043f\u0435\u0440\u0435\u0434 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0439 \u043f\u0440\u043e\u0434\u0430\u0432\u0449\u0438\u0446\u0435\u0439. \u041a\u0430\u0436\u0434\u044b\u0439 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u0442\u043e\u0440\u0430 \u0440\u0430\u0437\u0433\u043d\u0435\u0432\u0430\u043d\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043a\u0430\u0441\u0441\u0443 \u0438 \u043f\u0440\u0438&nbsp;\u044d\u0442\u043e\u043c \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043f\u0440\u0430\u0432 \u0432&nbsp;\u0442\u043e\u043c, \u0447\u0442\u043e&nbsp;\u0437\u0430\u0442\u043e\u0440 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c &#171;\u0440\u0430\u0441\u0441\u043e\u0441\u0435\u0442\u0441\u044f&#187; \u0432&nbsp;\u0434\u0432\u0430 \u0440\u0430\u0437\u0430&nbsp;\u0431\u044b\u0441\u0442\u0440\u0435\u0435.<\/em><\/p>\n<\/blockquote>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044e \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u0434\u0432\u0435\u0440\u0436\u0435\u043d\u044b \u043d\u0435 \u0432\u0441\u0435 \u0437\u0430\u0434\u0430\u0447\u0438. \u0417\u0434\u0435\u0441\u044c \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0430\u0442\u043e\u043c\u0430, \u043a\u0430\u043a \u043d\u0435\u0434\u0435\u043b\u0438\u043c\u043e\u0439 \u0447\u0430\u0441\u0442\u0438\u0446\u044b. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0440\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0430\u0436\u0435 \u0438 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0440\u0435\u0434\u043a\u043e \u0438 \u0437\u0430 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<h2>\u041a\u0430\u043a \u044d\u0442\u043e \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u0432 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435? \u041f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0438 \u043f\u043e\u0442\u043e\u043a\u0438<\/h2>\n<p>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u0431\u044b\u043b\u0430 \u0432\u0437\u044f\u0442\u0430 <a href=\"https:\/\/codernet.ru\/articles\/drugoe\/potok_i_proczessyi_v_operaczionnoj_sisteme_proczessore_i_programmirovanii\/\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a> \u0438 <a href=\"https:\/\/pyatilistnik.org\/difference-between-physical-cores-and-logical-processors\/\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a>. \u041f\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443, \u0434\u043b\u044f \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ul>\n<li>\n<p><strong>\u041f\u0440\u043e\u0446\u0435\u0441\u0441<\/strong> \u043d\u0430 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u2014 \u044d\u0442\u043e \u043b\u044e\u0431\u043e\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0431\u0440\u0430\u0443\u0437\u0435\u0440, \u0430\u043d\u0442\u0438\u0432\u0438\u0440\u0443\u0441\u043d\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, Skype \u0438 \u0434\u0440. \u2014 \u0432\u0441\u0435 \u044d\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u043d\u0430 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430 \u0432 \u0442\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435, \u0447\u0442\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0435\u0442 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u2014 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c \u0438 \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0434\u0438\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e <strong>\u043f\u043e\u0442\u043e\u043a\u043e\u0432 (Threads)<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u0412\u0430\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 \u043a\u043e\u0434\u0430 \u043e\u0434\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0434\u0435\u043b\u044f \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u043e\u0431\u0449\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u044b \u0438\u043c\u0435\u044e\u0442 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u044b, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044f\u0434\u0435\u0440. \u041a\u0430\u0436\u0434\u043e\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u044f\u0434\u0440\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a. \u0420\u0430\u043d\u044c\u0448\u0435 \u0431\u044b\u043b\u043e \u0442\u0430\u043a: \u043e\u0434\u043d\u043e \u044f\u0434\u0440\u043e \u0438\u043c\u0435\u043b\u043e \u043e\u0434\u0438\u043d \u044f\u0434\u0435\u0440\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a, \u0430 \u043e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a \u2014 \u044d\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0434\u0435\u043b\u0430\u0442\u044c \u044f\u0434\u0440\u0430 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u043c\u0438, \u0430 \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043e\u0434\u043d\u043e \u044f\u0434\u0440\u043e \u043c\u043e\u0436\u0435\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u0430\u043d\u0434 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0447\u0438\u0441\u043b\u043e\u043c  <strong>\u044f\u0434\u0435\u0440\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432<\/strong>. \u0413\u0440\u0443\u0431\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0435\u0441\u043b\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u044f\u0434\u0440\u0435 4 \u044f\u0434\u0435\u0440\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u0430, \u0442\u043e \u044f\u0434\u0440\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e 4 \u043a\u043e\u043c\u0430\u043d\u0434\u044b.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043b\u0435\u0433\u043a\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e <strong>\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432 <\/strong>(\u0447\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0447\u0438\u0441\u043b\u0443 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e), \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043d\u0430 \u0432\u0430\u0448\u0435\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435. \u0412 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 Windows 10 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c &#171;\u0414\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440 \u0437\u0430\u0434\u0430\u0447&#187; \u0438 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0432\u043a\u043b\u0430\u0434\u043a\u0443 &#171;\u0426\u041f&#187; \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 &#171;\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c&#187;. \u041d\u0430 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0435 \u043d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043c\u043e\u0435\u0433\u043e \u041f\u041a: 1 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439 6-\u0442\u0438 \u044f\u0434\u0435\u0440\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440, \u043a\u0430\u0436\u0434\u043e\u0435 \u044f\u0434\u0440\u043e \u0438\u043c\u0435\u0435\u0442 \u043f\u043e 2 \u044f\u0434\u0435\u0440\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u0430, \u0438 \u0442\u043e\u0433\u043e \u043c\u043d\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e 12 \u044f\u0434\u0435\u0440\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 (\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432) \u0432\u0441\u0435\u0433\u043e.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/66d\/c0e\/df2\/66dc0edf2ff08b232c8b1101bf83d163.png\" alt=\"\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043c\u043e\u0435\u0433\u043e \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430.\" title=\"\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043c\u043e\u0435\u0433\u043e \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430.\" width=\"734\" height=\"511\"><\/p>\n<div><figcaption>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043c\u043e\u0435\u0433\u043e \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430.<\/figcaption><\/div>\n<\/figure>\n<p>\u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430, \u043f\u0440\u0438\u0437\u043d\u0430\u044e\u0441\u044c, \u0447\u0442\u043e \u044f \u0432\u0430\u0441 \u043d\u0435\u043c\u043d\u043e\u0436\u043a\u043e \u043e\u0431\u043c\u0430\u043d\u0443\u043b. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0441\u043b\u043e\u0432\u043e <strong><em>&#171;\u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e&#187;<\/em><\/strong> \u0432\u0441\u044e\u0434\u0443 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 <strong><em>&#171;\u0443\u0441\u043b\u043e\u0432\u043d\u043e \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e&#187;<\/em><\/strong>. \u041f\u043e-\u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 &#171;\u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e&#187; \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u044f\u0434\u0440\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u0438 \u043d\u0430 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430.<\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0435\u0449\u0435 \u0440\u0430\u0437 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435. \u0417\u0430\u043f\u0443\u0449\u0435\u043d\u043e 259 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0435\u0442 \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c 1 \u043f\u043e\u0442\u043e\u043a (\u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f). \u041a\u0430\u043a \u0436\u0435 6-\u0442\u0438 \u044f\u0434\u0435\u0440\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u0442\u0430\u043a\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0437\u0430\u0434\u0430\u0447?<\/p>\n<p>\u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043e\u0442\u043e\u043a \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043b\u043e\u0434\u043e\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438. \u042f\u0434\u0440\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 \u0442\u0430\u043a\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u0442\u0440\u043e\u0433\u043e \u043e\u0434\u043d\u0443 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e, \u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u0437\u0430\u0434\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u0443\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c (&#171;\u043d\u0430 \u043f\u0430\u043b\u044c\u0446\u0430\u0445&#187;): \u043a\u0430\u0436\u0434\u043e\u0435 \u044f\u0434\u0440\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 &#171;\u043a\u0443\u0441\u043e\u0447\u0435\u043a&#187; \u0441\u0442\u0440\u043e\u0433\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430, \u0437\u0430\u0442\u0435\u043c &#171;\u0437\u0430\u043c\u043e\u0440\u0430\u0436\u0438\u0432\u0430\u0435\u0442&#187; \u0435\u0433\u043e, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044f \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u0446\u0438\u043a\u043b\u0443. \u0427\u0435\u043b\u043e\u0432\u0435\u043a\u0443 \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u044b \u043c\u043e\u043c\u0435\u043d\u0442\u044b &#171;\u0437\u0430\u043c\u043e\u0440\u043e\u0437\u043a\u0438&#187;, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043e\u0447\u0435\u043d\u044c \u043c\u0430\u043b\u044b (\u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0441\u043b\u0430\u0431\u044b\u0439, \u0442\u043e \u044d\u0444\u0444\u0435\u043a\u0442 &#171;\u0437\u0430\u043c\u043e\u0440\u043e\u0437\u043a\u0438&#187; \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u043f\u043e\u0434\u0442\u043e\u0440\u043c\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0439 \u0438\u043b\u0438 \u0434\u043e\u043b\u0433\u0438\u0445 \u0437\u0430\u0433\u0440\u0443\u0437\u043e\u043a). \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u041e\u0421 \u0443\u043c\u0435\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e, \u0440\u0430\u0441\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u044b \u043f\u0440\u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u043d\u0430 \u0430\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432.<\/p>\n<p>\u042d\u0442\u043e\u0442 \u0444\u0430\u043a\u0442 \u0441\u0442\u043e\u0438\u0442 \u0438\u043c\u0435\u0442\u044c \u0432\u0432\u0438\u0434\u0443, \u0442\u0430\u043a \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0443\u0441\u043a\u043e\u0440\u044f\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u0447\u0438\u0441\u043b\u043e \u0440\u0430\u0437, \u0440\u0430\u0432\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0438\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u0432.<\/p>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Thread Pool?<\/h2>\n<p><strong>\u041f\u0443\u043b \u043f\u043e\u0442\u043e\u043a\u043e\u0432 (Thread Pool)<\/strong> \u2014 \u044d\u0442\u043e \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0445 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430 \u0437\u0430\u0434\u0430\u0447\u0438, \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u043d\u044b\u0435 \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432. \u041c\u0430\u0441\u0441\u0438\u0432 \u0437\u0430\u0434\u0430\u0447 \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 <strong>\u043e\u0447\u0435\u0440\u0435\u0434\u0438 (Task Queue)<\/strong>.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/15d\/cb5\/cb7\/15dcb5cb75866cca80020afe3c892c39.png\" alt=\"\u041b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0443\u043b\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432.\" title=\"\u041b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0443\u043b\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432.\" width=\"1200\" height=\"621\"><\/p>\n<div><figcaption>\u041b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0443\u043b\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432.<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0443\u043b\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u2014 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c &#171;\u0441\u044b\u0440\u0443\u044e&#187; \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0432 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u0440\u0443\u0434\u043e\u0435\u043c\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447, \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0449\u0438\u0445 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0435 \u043d\u0430 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u043a\u0443\u0441\u043e\u0447\u043a\u0438.<\/p>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u043c \u043b\u043e\u0433\u0438\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b Thread Pool&#8217;\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u0430\u043a\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f <strong>\u0435\u0434\u0438\u043d\u043e\u0436\u0434\u044b<\/strong>. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439:<\/p>\n<blockquote>\n<p>1. \u0412 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0437\u0430\u0434\u0430\u0447 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<p>2. \u041f\u043e\u0434 \u0432\u043d\u043e\u0432\u044c \u043f\u0440\u0438\u0431\u044b\u0432\u0448\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0442\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0441\u0442\u0430\u0435\u0442 \u0435\u0435 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c.<\/p>\n<p>3. \u041f\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0434 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u043f\u043e\u0442\u043e\u043a \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0430\u0435\u0442\u0441\u044f.<\/p>\n<\/blockquote>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u043c \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439:<\/p>\n<blockquote>\n<p>1. \u0412 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0437\u0430\u0434\u0430\u0447 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<p>2. \u0417\u0430\u0434\u043e\u043b\u0433\u043e \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0432\u0441\u0435 \u043f\u043e\u0442\u043e\u043a\u0438, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0435\u0441\u044f \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f. \u0412\u043d\u043e\u0432\u044c \u043f\u0440\u0438\u0431\u044b\u0432\u0448\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0434\u043e\u0441\u0442\u0430\u0435\u0442 \u043b\u044e\u0431\u043e\u0439 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0438\u0437 \u043f\u0443\u043b\u0430 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0435\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c.<\/p>\n<p>3. \u041f\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0434 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u043f\u043e\u0442\u043e\u043a \u0441\u043d\u043e\u0432\u0430 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u0432 \u0440\u0435\u0436\u0438\u043c \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f.<\/p>\n<\/blockquote>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0442 \u0430\u0441\u043f\u0435\u043a\u0442 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0437\u043d\u0430\u043d\u0438\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u044f\u0437\u044b\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0442\u0430\u043a \u043a\u0430\u043a \u0437\u0430\u043f\u0443\u0441\u043a \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0442\u0440\u0443\u0434\u043e\u0435\u043c\u043a\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439.<\/p>\n<h2>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e C++<\/h2>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0443\u043b\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c \u0432\u0430\u0441 \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u044f\u0437\u044b\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f C++, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0442\u0435\u0445 \u0441\u0430\u043c\u044b\u0445 \u044f\u0434\u0435\u0440\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 (\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u044f\u0434\u0440\u0430\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430).<\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u043d\u0430\u043c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441 <code>std::thread<\/code>, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 <code>&lt;thread&gt;<\/code>.<\/p>\n<pre><code class=\"cpp\">#include &lt;iostream&gt; #include &lt;thread&gt; #include &lt;chrono&gt;  void sleep(int duration) { \/\/ simulate expensive operation std::this_thread::sleep_for(std::chrono::seconds(duration)); }  int main() { std::cout &lt;&lt; \"starting first thread...\\n\"; std::thread th1(sleep, 1);  std::cout &lt;&lt; \"starting second thread...\\n\"; std::thread th2(sleep, 2);  std::cout &lt;&lt; \"waiting for threads to finish...\\n\";  th1.join(); std::cout &lt;&lt; \"the first thread finished\\n\";  th2.join(); std::cout &lt;&lt; \"the second thread finished\\n\";  std::cout &lt;&lt; \"done\\n\";  return 0; }<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435, \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442, \u043a\u0430\u043a \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>std::thread<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0435\u0435 \u0432\u044b\u0437\u043e\u0432\u0430. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u0442\u043e\u043a \u0442\u0443\u0442 \u0436\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0435\u043b\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0449\u0435\u0439 \u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b &#171;\u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f&#187; \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e\u0442\u043e\u043a\u0430 (\u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0439 \u0435\u043c\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0438) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>std::thread::join()<\/code>. \u0422\u0430\u043a\u0436\u0435, \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e <code>std::thread::join()<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u043c\u0435\u0442\u043e\u0434 <code>std::thread::detach()<\/code>, \u043d\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0434\u0430\u043d\u043d\u0430\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.<\/p>\n<h2>\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432<\/h2>\n<p>\u0418\u0442\u0430\u043a, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c. \u0410 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0434\u0432\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u0430 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0449\u0438\u0439 \u0440\u0435\u0441\u0443\u0440\u0441?<\/p>\n<pre><code class=\"cpp\">#include &lt;iostream&gt; #include &lt;thread&gt; #include &lt;chrono&gt;  void func(int a) { for (int i = 0; i &lt; 3; i++) { std::cout &lt;&lt; a + i; std::this_thread::sleep_for(std::chrono::seconds(1)); std::cout &lt;&lt; \" \"; } std::cout &lt;&lt; \"\\n\"; }  int main() {  std::thread th1(func, 1); std::thread th2(func, 4);  th1.join(); th2.join();  return 0; }<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u043d\u0435\u0437\u0430\u0434\u0430\u0447\u0430, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437, \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u043e\u0431\u0449\u0435\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u0430 (\u0437\u0434\u0435\u0441\u044c \u043f\u043e\u0442\u043e\u043a \u0432\u044b\u0432\u043e\u0434\u0430 <code>std::cout<\/code>) \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0441\u0442\u0438 \u0441\u0435\u0431\u044f \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e. \u041d\u0435\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043e\u0431\u0449\u0438\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043a \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0431\u043e\u043b\u0435\u0435 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f\u043c (\u043e\u0448\u0438\u0431\u043a\u0438, \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f).<\/p>\n<p>\u0422\u0443\u0442 \u0432 \u0438\u0433\u0440\u0443 \u0432\u0441\u0442\u0443\u043f\u0430\u0435\u0442 <strong>\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432<\/strong>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f\u0437\u044b\u043a C++ \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u0432 \u0432\u0438\u0434\u0435 \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 (\u0448\u0430\u0431\u043b\u043e\u043d <code>std::atomic<\/code>, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0432 <code>&lt;atomic&gt;<\/code>) \u0438 \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u043e\u0432 (\u043a\u043b\u0430\u0441\u0441 <code>std::mutex<\/code>, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0432 <code>&lt;mutex&gt;<\/code>). \u0417\u0430\u0434\u0430\u0447\u0430 \u044d\u0442\u0438\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u2014 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c (\u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e) \u043e\u0431\u0449\u0438\u0435 \u0434\u043b\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0438 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u0434\u0430, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u043f\u043e\u0442\u043e\u043a\u0443 (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0432\u044b\u043c \u0434\u043e\u0431\u0440\u0430\u043b\u0441\u044f \u0434\u043e \u043d\u0438\u0445), \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044f \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c <strong>\u043f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c<\/strong>. \u0422\u0430\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0431\u044a\u0435\u043a\u0442 \u043b\u044e\u0431\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 <code>std::atomic<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u0435\u0434\u0438\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438.<\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c &#171;\u043f\u043e\u0447\u0438\u043d\u0438\u0442\u044c&#187; \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u043e\u0431\u0449\u0435\u0433\u043e \u0434\u043b\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u0430 <code>std::mutex mtx<\/code>.<\/p>\n<pre><code class=\"cpp\">#include &lt;iostream&gt; #include &lt;thread&gt; #include &lt;chrono&gt; #include &lt;mutex&gt;  std::mutex mtx;  void func(int a) { mtx.lock(); for (int i = 0; i &lt; 3; i++) { std::cout &lt;&lt; a + i; std::this_thread::sleep_for(std::chrono::seconds(1)); std::cout &lt;&lt; \" \"; } std::cout &lt;&lt; \"\\n\"; mtx.unlock(); }  int main() {  std::thread th1(func, 1); std::thread th2(func, 4);  th1.join(); th2.join();  return 0; }<\/code><\/pre>\n<p>\u0414\u0430, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043d\u0435\u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u0435\u043d, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a\u043e\u0439 \u0438\u0437 \u0434\u0432\u0443\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u043a \u0437\u0430\u0449\u0438\u0449\u0435\u043d\u043d\u043e\u043c\u0443 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0443 \u043a\u043e\u0434\u0430 \u0434\u043e\u0441\u0442\u0443\u043f \u043f\u0435\u0440\u0432\u0435\u0435, \u043d\u043e \u0432\u0441\u0435 \u0436\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c.<\/p>\n<p>\u042f \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043a\u0430\u043a \u0438 \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u044b. \u0411\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0432\u0430\u043c \u0441\u0430\u043c\u0438\u043c. \u042f \u043b\u0438\u0448\u044c \u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0438 \u043a\u043b\u0430\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u043e\u0433\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u0430\u043c\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 \u043c\u043e\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 Thread Pool&#8217;\u0430:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"228\" width=\"228\">\n<p align=\"left\"><strong>\u041a\u043b\u0430\u0441\u0441<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\"><strong>\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u041a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"228\" width=\"228\">\n<p align=\"left\"><code>std::lock_guard<\/code><\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\"><code>&lt;mutex&gt;<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0411\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 &#171;\u0437\u0430\u0445\u0432\u0430\u0447\u0435\u043d\u043d\u044b\u0439&#187; \u043c\u044c\u044e\u0442\u0435\u043a\u0441 \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"228\" width=\"228\">\n<p align=\"left\"><code>std::unique_lock<\/code><\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\"><code>&lt;mutex&gt;<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0420\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b &#171;\u0437\u0430\u0445\u0432\u0430\u0447\u0435\u043d\u043d\u043e\u0433\u043e&#187; \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0441 <code>std::condition_variable<\/code>.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"228\" width=\"228\">\n<p align=\"left\"><code>std::scoped_lock<\/code><\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\"><code>&lt;mutex&gt;<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u043e\u0445\u043e\u0436 \u043d\u0430 <code>std::lock_guard<\/code>, \u043d\u043e \u0443\u043c\u0435\u0435\u0442 &#171;\u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c&#187; \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u043e\u0432 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0430\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0437\u0430\u0438\u043c\u043d\u0443\u044e \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0443 (deadlock).<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"228\" width=\"228\">\n<p align=\"left\"><code>std::condition_variable<\/code><\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\"><code>&lt;condition_variable&gt;<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u043e\u0434\u0438\u043d \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u043d\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u0438\u0442 \u043e \u0441\u043d\u044f\u0442\u0438\u0438 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e. &#171;\u0417\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442&#187; \u043e\u0431\u044a\u0435\u043a\u0442 <code>std::unique_lock&lt;std::mutex&gt;<\/code><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043c\u043d\u043e\u0433\u043e\u0435 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c, \u043d\u043e \u043d\u0435 \u0432\u0441\u0435 \u0441\u0440\u0430\u0437\u0443. \u042f \u0432 \u0441\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0443\u0433\u0440\u043e\u0431\u0438\u043b \u0443\u0439\u043c\u0443 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e-\u0447\u0430\u0441\u043e\u0432 \u043d\u0430 \u043f\u043e\u0437\u043d\u0430\u043d\u0438\u0435 \u0438\u0441\u0442\u0438\u043d\u044b. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444\u0435 \u044f \u0441\u043a\u043e\u0440\u0435\u0435 \u0441\u0442\u0430\u0432\u0438\u043b \u0441\u0435\u0431\u0435 \u0437\u0430\u0434\u0430\u0447\u0443 &#171;\u043f\u043e\u0434\u0441\u0432\u0435\u0442\u0438\u0442\u044c&#187; \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432, \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0438\u0445 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f, \u0447\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u0441\u043e\u0431\u0438\u0435.<\/p>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0443\u043b\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 C++<\/h2>\n<p>\u0427\u0438\u0442\u0430\u044e \u0425\u0430\u0431\u0440 \u044f \u0443\u0436\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0434\u0430\u0432\u043d\u043e, \u0438 \u0432 \u043f\u0435\u0440\u0438\u043e\u0434 \u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u043d\u044f &#171;\u043f\u043e\u0432\u0435\u043b\u0438\u0442\u0435\u043b\u0435\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u0432&#187; \u044f \u043d\u0430\u0442\u043a\u043d\u0443\u043b\u0441\u044f \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e <a href=\"https:\/\/habr.com\/ru\/articles\/656515\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a>. \u041f\u0440\u0438\u0437\u043d\u0430\u044e\u0441\u044c \u0447\u0435\u0441\u0442\u043d\u043e, \u0437\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 \u0441\u0432\u043e\u0435\u0433\u043e Thread Pool&#8217;\u0430 \u044f \u0432\u0437\u044f\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043c (<a href=\"https:\/\/github.com\/YFatMR\/Habr\/blob\/main\/thread_pool\/best_version.cpp\" rel=\"noopener noreferrer nofollow\">\u0431\u0430\u0437\u043e\u0432\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/a>).<\/p>\n<p>\u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0430\u0434\u0430\u043f\u0442\u0430\u0446\u0438\u0438 \u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u043e\u0437\u0430\u0438\u043c\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0438\u0434\u0435\u0439, \u044f \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b \u043f\u0435\u0440\u0435\u0434 \u0441\u043e\u0431\u043e\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438:<\/p>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u043f\u0443\u043b\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0432 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u043e\u0441\u0442\u043e\u0439\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u043e\u0442\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u043f\u0443\u043b\u0443 \u0437\u0430\u0434\u0430\u043d\u0438\u0439.<\/p>\n<\/li>\n<li>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0435 \u0434\u0432\u0443\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 Thread Pool&#8217;\u0430 \u0441 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u043c\u0438 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438 \u0438 \u0440\u0435\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043f\u043e\u0438\u0441\u043a\u0430 &#171;\u0440\u0435\u0434\u043a\u043e\u0433\u043e \u0443\u0441\u043f\u0435\u0445\u0430&#187;.<\/p>\n<\/li>\n<\/ol>\n<p>\u0421 \u043f\u0435\u0440\u0432\u044b\u043c \u043f\u0443\u043d\u043a\u0442\u043e\u043c, \u0432\u0440\u043e\u0434\u0435, \u0432\u0441\u0435 \u044f\u0441\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u043e\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u044e \u043f\u0443\u043d\u043a\u0442 \u043f\u043e\u0434 \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u0434\u0432\u0430. \u041f\u043e\u0434 &#171;\u0440\u0435\u0434\u043a\u0438\u043c \u0443\u0441\u043f\u0435\u0445\u043e\u043c&#187; \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c &#171;\u0438\u0433\u043e\u043b\u043a\u0443 \u0432 \u0441\u0442\u043e\u0433\u0435 \u0441\u0435\u043d\u0430&#187;. \u041f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c \u0441 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439.<\/p>\n<blockquote>\n<p><em>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0441\u0435\u0431\u0435, \u043a\u0430\u043a \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0432\u0430\u0440\u0438\u0449\u0435\u0439 \u0431\u0435\u0437\u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u043d\u043e \u0431\u0435\u0440\u0435\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u044e\u0442 \u0441\u043e\u043b\u043e\u043c\u0438\u043d\u043a\u0443 \u0437\u0430 \u0441\u043e\u043b\u043e\u043c\u0438\u043d\u043a\u043e\u0439, \u043d\u0430\u0445\u043e\u0434\u044f \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043a\u0430\u0436\u0443\u0449\u0438\u0435\u0441\u044f \u0441\u0445\u043e\u0434\u0441\u0442\u0432\u0430 \u0441 \u0437\u0430\u0432\u0435\u0442\u043d\u043e\u0439 \u0438\u0433\u043e\u043b\u043e\u0447\u043a\u043e\u0439. \u0421\u043f\u0443\u0441\u0442\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u043e\u0432 \u043a\u0440\u043e\u043f\u043e\u0442\u043b\u0438\u0432\u044b\u0445 \u043f\u043e\u0438\u0441\u043a\u043e\u0432 \u043e\u0434\u0438\u043d \u0438\u0437 \u0434\u0440\u0443\u0437\u0435\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 &#171;\u0441\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u0431\u0435\u0433\u043b\u044f\u043d\u043a\u0443&#187;. \u0420\u0430\u0431\u043e\u0442\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430, \u0443\u0441\u043f\u0435\u0445 \u043f\u043e\u043b\u0443\u0447\u0435\u043d, \u0434\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u0432\u0441\u0435\u043c \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043c\u0443\u0447\u0435\u043d\u0438\u044f!<\/em><\/p>\n<\/blockquote>\n<p>\u041d\u0443 \u0430 \u0435\u0441\u043b\u0438 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u043e, \u043f\u0443\u043b \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0433\u0438\u0431\u043a\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0439, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0443\u043b\u0443 \u043f\u043e\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u0433\u043d\u0430\u043b.<\/p>\n<p>\u041b\u044e\u0431\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443, \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0449\u0443\u044e \u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 Thread Pool&#8217;\u043e\u043c \u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u043e\u043c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 <code>Task<\/code>:<\/p>\n<pre><code class=\"cpp\">namespace MT { typedef unsigned long long int task_id;  \/\/ \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0437\u0430\u0434\u0430\u0447\u0438 class Task { friend class ThreadPool; public: enum class TaskStatus { awaiting, completed };  Task(const std::string&amp; _description);  \/\/ \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u0434\u0430\u0447\u0438 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u043f\u0443\u043b\u0443 \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 void send_signal();  \/\/ \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c, \/\/ \u0432 \u0442\u0435\u043b\u0435 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0442\u0440\u0430\u043a\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 void virtual one_thread_method() = 0;  protected: MT::Task::TaskStatus status; \/\/ \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 (\u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u043a\u0440\u0430\u0441\u0438\u0432\u043e\u0433\u043e \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f) std::string description; \/\/ \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0437\u0430\u0434\u0430\u0447\u0438 MT::task_id id;  MT::ThreadPool* thread_pool;  \/\/ \u043c\u0435\u0442\u043e\u0434, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u044b\u0439 \u043f\u043e\u0442\u043e\u043a\u043e\u043c void one_thread_pre_method(); }; }<\/code><\/pre>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0438\u043c\u0435\u0435\u0442 \u043a\u0430\u043a \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430, \u0442\u0430\u043a \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438.<\/p>\n<p>\u041f\u043b\u044e\u0441\u044b:<\/p>\n<ul>\n<li>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442 \u0437\u0430\u0434\u0430\u0447\u0438 \u0443\u0436\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0431\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0434\u043b\u044f \u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0430 \u043f\u043e\u0442\u043e\u043a\u0430\u043c \u043f\u0443\u043b\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043b\u0438\u0448\u044c \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>Task::one_thread_pre_method()<\/code>, \u043d\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0439 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043b\u0438\u0448\u043d\u0438\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u0441\u0438\u043b\u0443 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0441\u0442\u0438 \u0443 <code>Task<\/code>, \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c &#171;\u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435&#187; \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041c\u043d\u043e\u0433\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u0438\u0434\u0430 <code>template &lt;typename FuncRetType, typename ...Args, typename ...FuncTypes&gt; Task(FuncRetType(*func)(FuncTypes...), Args&amp;&amp;... args)<\/code>, \u0447\u0442\u043e \u0432\u043b\u0435\u0447\u0435\u0442 \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 &#171;\u043f\u0440\u043e\u0442\u044f\u0433\u0438\u0432\u0430\u043d\u0438\u0435&#187; \u043a\u0443\u0447\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u0430\u0435\u0442 \u043f\u0440\u043e\u0435\u043a\u0442 \u0431\u043e\u043b\u0435\u0435 \u0442\u044f\u0436\u0435\u043b\u043e\u0439 \u043e\u0442\u043b\u0430\u0434\u043a\u0435. \u0412 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0435, \u043d\u043e \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0437\u0430\u0434\u0430\u0447 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u044b \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u0430 \u043d\u0435 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u0438\u043d\u0443\u0441\u044b:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u0434 \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u0438\u0434 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u0446\u0435\u043b\u044b\u0439 \u043a\u043b\u0430\u0441\u0441. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u043c, \u0447\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432\u043b\u0430\u0434\u0435\u043d\u0438\u0435 \u043d\u0430\u0432\u044b\u043a\u0430\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041d\u0438\u043a\u0442\u043e \u043d\u0435 \u043e\u0442\u043c\u0435\u043d\u044f\u043b \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435\u043c.<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u043b\u0430\u0441\u0441 <code>ThreadPool<\/code> \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0443\u043b \u043f\u043e\u0442\u043e\u043a\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">namespace MT {     \/\/ \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u043d\u0430\u0434 std::thread \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \/\/ \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 struct Thread { std::thread _thread; std::atomic&lt;bool&gt; is_working; };  class ThreadPool {  friend void MT::Task::send_signal();  public: ThreadPool(int count_of_threads);  \/\/ \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c template &lt;typename TaskChild&gt; MT::task_id add_task(const TaskChild&amp; task);  \/\/ \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0437\u0430\u0434\u0430\u0447 \u0438\u043b\u0438 \u043f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438, \/\/ \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 id \u0437\u0430\u0434\u0430\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u043f\u043e\u0434\u0430\u043b\u0430 \u0441\u0438\u0433\u043d\u0430\u043b \u0438 0 \u0438\u043d\u0430\u0447\u0435 MT::task_id wait_signal();  \/\/ \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0437\u0430\u0434\u0430\u0447, \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044f \u043b\u044e\u0431\u044b\u0435 \/\/ \u0441\u0438\u0433\u043d\u0430\u043b\u044b \u043e \u043f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 void wait();  \/\/ \u043f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 void stop();  \/\/ \u0432\u043e\u0437\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 void start();  \/\/ \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043f\u043e id template &lt;typename TaskChild&gt; std::shared_ptr&lt;TaskChild&gt; get_result(MT::task_id id);  \/\/ \u043e\u0447\u0438\u0441\u0442\u043a\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 void clear_completed();  \/\/ \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0444\u043b\u0430\u0433\u0430 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f void set_logger_flag(bool flag);  ~ThreadPool();  private: \/\/ \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u044b, \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0434\u043b\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f std::mutex task_queue_mutex; std::mutex completed_tasks_mutex; std::mutex signal_queue_mutex;  \/\/ \u043c\u044c\u044e\u0442\u0435\u043a\u0441, \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043b\u043e\u0433\u0435\u0440 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430 std::mutex logger_mutex;  \/\/ \u043c\u044c\u044e\u0442\u0435\u043a\u0441, \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0436\u0438\u0434\u0430\u044e\u0449\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b (\u043c\u0435\u0442\u043e\u0434\u044b wait*) std::mutex wait_mutex;  std::condition_variable tasks_access; std::condition_variable wait_access;  \/\/ \u043d\u0430\u0431\u043e\u0440 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 std::vector&lt;MT::Thread*&gt; threads;  \/\/ \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0437\u0430\u0434\u0430\u0447 std::queue&lt;std::shared_ptr&lt;Task&gt;&gt; task_queue; MT::task_id last_task_id;  \/\/ \u043c\u0430\u0441\u0441\u0438\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u0432 \u0432\u0438\u0434\u0435 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b std::unordered_map&lt;MT::task_id, std::shared_ptr&lt;Task&gt;&gt; completed_tasks; unsigned long long completed_task_count;  std::queue&lt;task_id&gt; signal_queue;  \/\/ \u0444\u043b\u0430\u0433 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0443\u043b\u0430 std::atomic&lt;bool&gt; stopped; \/\/ \u0444\u043b\u0430\u0433 \u043f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b std::atomic&lt;bool&gt; paused; std::atomic&lt;bool&gt; ignore_signals; \/\/ \u0444\u043b\u0430\u0433, \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0439 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f std::atomic&lt;bool&gt; logger_flag;  Timer timer;  \/\/ \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0449\u0430\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u043e\u0442\u043e\u043a void run(MT::Thread* thread);  \/\/ \u043f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 c \u0432\u044b\u0431\u0440\u043e\u0441\u043e\u043c \u0441\u0438\u0433\u043d\u0430\u043b\u0430 void receive_signal(MT::task_id id);  \/\/ \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 bool run_allowed() const;  \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0437\u0430\u0434\u0430\u0447 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 bool is_comleted() const;  \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0437\u0430\u043d\u044f\u0442\u043e\u0441\u0442\u0438 \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 bool is_standby() const; }; }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b &#171;\u0443\u043c\u043d\u044b\u0435&#187; \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 <code>std::shared_ptr<\/code>. \u042d\u0442\u043e, \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437 \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <code>Task<\/code> (<em>upcasting<\/em>) \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e (<em>downcasting<\/em>) \u043f\u0440\u0438 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 (&#171;\u0438\u0433\u0440\u0430 \u043d\u0430 \u043f\u043e\u043d\u0438\u0436\u0435\u043d\u0438\u0435&#187; \u043f\u0440\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0438 \u0442\u0438\u043f\u043e\u0432 \u0437\u0432\u0443\u0447\u0438\u0442 \u043e\u043f\u0430\u0441\u043d\u043e \u0438 &#171;\u043a\u043e\u0441\u0442\u044b\u043b\u044c\u043d\u043e&#187;, \u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442).<\/p>\n<p>\u0420\u0435\u0448\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435 <code>ThreadPool::completed_tasks<\/code>. \u0422\u0430\u043a\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0431\u044b\u043b \u0432\u044b\u0431\u0440\u0430\u043d \u0438\u0437 \u0441\u043e\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443.<\/p>\n<p>\u0410\u0442\u0440\u0438\u0431\u0443\u0442 <code>ThreadPool::timer<\/code> \u2014 \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 <code>Timer<\/code> \u0434\u043b\u044f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043a \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u043e\u043d \u043d\u0435 \u0438\u043c\u0435\u0435\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443\u0433\u043b\u0443\u0431\u043b\u044f\u0442\u044c\u0441\u044f \u0432 \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u044f \u043d\u0435 \u0431\u0443\u0434\u0443. \u0412\u0441\u0435, \u0447\u0442\u043e \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442, \u044d\u0442\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u0438 &#171;\u043a\u0440\u0430\u0441\u0438\u0432\u043e&#187; \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u0421 \u043a\u043b\u0430\u0441\u0441\u043e\u043c <code>Task<\/code> \u0432\u0441\u0435 \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<pre><code class=\"cpp\">MT::Task::Task(const std::string&amp; _description) { description = _description; id = 0; status = MT::Task::TaskStatus::awaiting; thread_pool = nullptr; }  void MT::Task::send_signal() { thread_pool-&gt;receive_signal(id); }  void MT::Task::one_thread_pre_method() { one_thread_method(); status = MT::Task::TaskStatus::completed; }<\/code><\/pre>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e <code>Task::id<\/code> \u0441\u0432\u043e\u044e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0430\u0435\u0442 \u043d\u0435 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0430 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0437\u0430\u0434\u0430\u0447 (<code>ThreadPool::add_task<\/code>) \u0438 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c. \u0422\u0430\u043a\u0436\u0435 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u0432\u044f\u0437\u0430\u043d \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0435\u0435 \u043f\u0443\u043b \u043f\u043e\u0442\u043e\u043a\u043e\u0432 (<code>Task::thread_pool<\/code> \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e <code>nullptr<\/code>). \u042d\u0442\u043e\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u0438 \u0441 \u043f\u0443\u043b\u043e\u043c, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u043f\u043e\u0434\u0430\u0447\u0438 \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432 \u043e \u043f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 Thread Pool&#8217;\u0443 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 <code>Task::send_signal()<\/code>.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u0431 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 <code>ThreadPool<\/code>.<\/p>\n<pre><code class=\"cpp\">MT::ThreadPool::ThreadPool(int count_of_threads) { stopped = false; paused = true; logger_flag = false; last_task_id = 0; completed_task_count = 0; ignore_signals = true; for (int i = 0; i &lt; count_of_threads; i++) { MT::Thread* th = new MT::Thread; th-&gt;_thread = std::thread{ &amp;ThreadPool::run, this, th }; th-&gt;is_working = false; threads.push_back(th); } }<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043f\u0443\u043b \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f (\u0444\u043b\u0430\u0433 <code>ThreadPool::paused<\/code> \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e <code>true<\/code>).<\/p>\n<p>\u0424\u043b\u0430\u0433 <code>ThreadPool::stopped<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u043e \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 <code>false<\/code> \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430. \u041e\u043d \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043f\u0443\u043b \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432\u0441\u0435 \u0435\u0449\u0435 &#171;\u0436\u0438\u0432&#187; \u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0449\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0441 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430<code>ThreadPool::run<\/code>, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0435\u0431\u044f \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f (\u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u043b\u0430\u0433\u043e\u043c <code>Thread::is_working<\/code>):<\/p>\n<pre><code class=\"cpp\">bool MT::ThreadPool::run_allowed() const { return (!task_queue.empty() &amp;&amp; !paused); }  void MT::ThreadPool::run(MT::Thread* _thread) { while (!stopped) { std::unique_lock&lt;std::mutex&gt; lock(task_queue_mutex);  \/\/ \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043f\u043e\u0442\u043e\u043a \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \/\/ \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u0437\u0430\u0434\u0430\u043d\u0438\u0439 \u043b\u0438\u0431\u043e \u0440\u0430\u0431\u043e\u0442\u0430 \u0432\u0441\u0435\u0433\u043e \u043f\u0443\u043b\u0430 \u043f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430 _thread-&gt;is_working = false; tasks_access.wait(lock, [this]()-&gt;bool { return run_allowed() || stopped; }); _thread-&gt;is_working = true;  if (run_allowed()) { \/\/ \u043f\u043e\u0442\u043e\u043a \u0434\u043e\u0441\u0442\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 auto elem = std::move(task_queue.front()); task_queue.pop(); lock.unlock();  if (logger_flag) { std::lock_guard&lt;std::mutex&gt; lg(logger_mutex); std::cout &lt;&lt; timer.make_checkpoint(\"Run task \" + elem-&gt;description) &lt;&lt; std::endl; } \/\/ \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 elem-&gt;one_thread_pre_method(); if (logger_flag) { std::lock_guard&lt;std::mutex&gt; lg(logger_mutex); std::cout &lt;&lt; timer.make_checkpoint(\"End task \" + elem-&gt;description) &lt;&lt; std::endl; }  \/\/ \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 std::lock_guard&lt;std::mutex&gt; lg(completed_tasks_mutex); completed_tasks[elem-&gt;id] = elem; completed_task_count++; } \/\/ \u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0438 \u043f\u0443\u043b\u0430 (\u043c\u0435\u0442\u043e\u0434\u044b wait*) wait_access.notify_all(); } }<\/code><\/pre>\n<p>\u0422\u0443\u0442 \u0441\u043a\u0430\u0436\u0443 \u043b\u0438\u0448\u044c \u043f\u0430\u0440\u0443 \u0441\u043b\u043e\u0432 \u043e\u0431 \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>ThreadPool::wait_access<\/code>.  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u0447\u044c \u0438\u0434\u0435\u0442 \u043e \u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u0432\u044b\u0437\u0432\u0430\u0432\u0448\u0438\u0445 \u0442\u0430\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u0430\u043a <code>ThreadPool::wait()<\/code> \u0438 <code>ThreadPool::wait_signal()<\/code>, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>main<\/code>. \u041e\u0431 \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435.<\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0440\u0435\u0448\u0435\u043d\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043a\u043b\u0430\u0434\u0435\u0442\u0441\u044f \u0432 <code>ThreadPool::completed_tasks<\/code> \u0432 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u043f\u043e \u043a\u043b\u044e\u0447\u0443 <code>Task::id<\/code>. \u041c\u043d\u043e\u044e \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u043d\u0435 \u0432\u0432\u043e\u0434\u0438\u0442\u044c \u0438\u0437\u043b\u0438\u0448\u043d\u0438\u0445 \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u0439 \u0432 \u0432\u0438\u0434\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442 \u043d\u0443\u0436\u043d\u044b\u0435 \u0435\u043c\u0443 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0432 \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u044b \u0438\u043b\u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u044b \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 <code>Task::one_thread_method()<\/code>.<\/p>\n<pre><code class=\"cpp\">void MT::ThreadPool::start() { if (paused) { paused = false; \/\/ \u0434\u0430\u0435\u043c \u0432\u0441\u0435\u043c \u043f\u043e\u0442\u043e\u043a\u0430\u043c \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0439 \u0441\u0438\u0433\u043d\u0430\u043b \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \/\/ \u043a \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043d\u0435\u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 tasks_access.notify_all(); } }  void MT::ThreadPool::stop() { paused = true; }  void MT::ThreadPool::receive_signal(MT::task_id id) { std::lock_guard&lt;std::mutex&gt; lock(signal_queue_mutex); signal_queue.emplace(id); if (!ignore_signals) stop(); }<\/code><\/pre>\n<p>\u041f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b <code>ThreadPool::start()<\/code> \u0438 <code>ThreadPool::stop()<\/code> \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u043f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0438 \u0432\u043e\u0437\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0443\u043b\u0430 \u0432 \u0442\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435, \u0447\u0442\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442 \u043f\u043e\u0442\u043e\u043a\u0438 \u0432 \u0440\u0435\u0436\u0438\u043c \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 (\u0432\u0430\u0436\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u0442\u043e\u043a\u0438 \u043d\u0435 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0430\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u044b). \u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>ThreadPool::receive_signal(*)<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u0440\u0443\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>Task::send_signal()<\/code>. \u042d\u0442\u043e\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0430\u0436\u043d\u043e\u0439 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0439 \u043f\u0440\u0438 \u043e\u0442\u043b\u0430\u0432\u043b\u0438\u0432\u0430\u043d\u0438\u0438 &#171;\u0440\u0435\u0434\u043a\u043e\u0433\u043e \u0443\u0441\u043f\u0435\u0445\u0430&#187; \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>ThreadPool::wait_signal()<\/code>, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u044f \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e \u043d\u0435\u0445\u0438\u0442\u0440\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443:<\/p>\n<pre><code class=\"cpp\">template &lt;typename TaskChild&gt; MT::task_id add_task(const TaskChild&amp; task) {     std::lock_guard&lt;std::mutex&gt; lock(task_queue_mutex);     task_queue.push(std::make_shared&lt;TaskChild&gt;(task));     \/\/ \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 id \u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435     \/\/ \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 id \u0440\u0430\u0432\u043d\u043e 1     task_queue.back()-&gt;id = ++last_task_id;     \/\/ \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u0441 \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u043f\u0443\u043b\u043e\u043c     task_queue.back()-&gt;thread_pool = this;     tasks_access.notify_one();     return last_task_id; }<\/code><\/pre>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043d\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u0442\u0438\u043f <code>TaskChild<\/code> \u043d\u0435\u0433\u043b\u0430\u0441\u043d\u043e \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u044b\u0442\u044c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 <code>Task<\/code>. \u0422\u0430\u043a\u0436\u0435, \u0437\u0434\u0435\u0441\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>tasks_access.notify_one()<\/code> \u043f\u043e\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0439 \u0441\u0438\u0433\u043d\u0430\u043b \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 (\u043d\u0435\u0432\u0430\u0436\u043d\u043e \u043a\u0430\u043a\u043e\u043c\u0443), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 &#171;\u0437\u0430\u0441\u0442\u0440\u044f\u043b&#187; \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c \u043c\u0435\u0441\u0442\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>ThreadPool::run<\/code>.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443 \u0437\u0430\u0434\u0430\u0447\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u0440\u0435\u0448\u0435\u043d\u0430 \u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0430 \u0432 <code>ThreadPool::completed_tasks<\/code>:<\/p>\n<pre><code class=\"cpp\">template &lt;typename TaskChild&gt; std::shared_ptr&lt;TaskChild&gt; get_result(MT::task_id id) {     auto elem = completed_tasks.find(id);     if (elem != completed_tasks.end())         return std::reinterpret_pointer_cast&lt;TaskChild&gt;(elem-&gt;second);     else         return nullptr; }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u0432\u043d\u0443\u0442\u0440\u0438 <code>ThreadPool::get_result<\/code>, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0437\u043d\u0430\u0442\u044c \u0442\u0438\u043f \u0437\u0430\u0434\u0430\u0447\u0438. \u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043d\u0435\u0441\u0442\u0438 \u043a \u043c\u0438\u043d\u0443\u0441\u0430\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0432\u0441\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0449\u0438\u0435 \u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443, \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0438\u043c\u0435\u044e\u0442 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043e\u0433\u043e\u0432\u043e\u0440\u0435\u043d\u043d\u044b\u0439 \u0440\u0430\u043d\u0435\u0435 \u0442\u0438\u043f.<\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u0430\u043c, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u043c \u043e\u0436\u0438\u0434\u0430\u044e\u0449\u0438\u043c\u0438 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438:<\/p>\n<pre><code class=\"cpp\">bool MT::ThreadPool::is_comleted() const { return completed_task_count == last_task_id; }  bool MT::ThreadPool::is_standby() const { if (!paused) return false; for (const auto&amp; thread : threads) if (thread-&gt;is_working) return false; return true; }  void MT::ThreadPool::wait() { std::lock_guard&lt;std::mutex&gt; lock_wait(wait_mutex);  start();  std::unique_lock&lt;std::mutex&gt; lock(task_queue_mutex); wait_access.wait(lock, [this]()-&gt;bool { return is_comleted(); });  stop(); }  MT::task_id MT::ThreadPool::wait_signal() { std::lock_guard&lt;std::mutex&gt; lock_wait(wait_mutex);  ignore_signals = false;  signal_queue_mutex.lock(); if (signal_queue.empty()) start(); else stop(); signal_queue_mutex.unlock();  std::unique_lock&lt;std::mutex&gt; lock(task_queue_mutex); wait_access.wait(lock, [this]()-&gt;bool { return is_comleted() || is_standby(); });  ignore_signals = true;  \/\/ \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0441\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u043e id \u0438\u0437 \/\/ \u043e\u0447\u0435\u0440\u0435\u0434\u0438 signal_queue \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u043c\u0438 std::lock_guard&lt;std::mutex&gt; lock_signals(signal_queue_mutex); if (signal_queue.empty()) return 0; else { MT::task_id signal = std::move(signal_queue.front()); signal_queue.pop(); return signal; } }<\/code><\/pre>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>ThreadPool::wait()<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0442\u0435\u043a\u0443\u0449\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 <code>ThreadPool::task_queue<\/code>, \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044f \u0441\u0438\u0433\u043d\u0430\u043b\u044b \u043e\u0431 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435. \u041e\u0441\u043e\u0431\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>ThreadPool::wait_signal()<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0448\u0430\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043f\u043e\u0438\u0441\u043a\u0430 &#171;\u0440\u0435\u0434\u043a\u043e\u0433\u043e \u0443\u0441\u043f\u0435\u0445\u0430&#187;. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0441\u0442\u0430\u0432\u0438\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043d\u0430 \u043f\u0430\u0443\u0437\u0443, \u0434\u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0441\u0442\u0438 <code>ThreadPool::is_standby()<\/code> \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0437\u0430\u0434\u0430\u0447\u0438, \u043f\u043e\u0434\u0430\u0432\u0448\u0435\u0439 \u0441\u0438\u0433\u043d\u0430\u043b \u043f\u0435\u0440\u0432\u0435\u0435 \u0432\u0441\u0435\u0445. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0435\u0441\u043b\u0438 \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0443\u0441\u043f\u0435\u0445\u0430 \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e, \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f <code>0<\/code>. \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0443\u0441\u043f\u0435\u0445\u043e\u0432, \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u0438\u0445 \u0443\u0442\u0435\u0440\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 <code>id<\/code> \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043d\u0435\u0441\u0435\u043d\u044b \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c <code>ThreadPool::signal_queue<\/code>.<\/p>\n<p>\u041e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u0435\u0449\u0435 \u043f\u0430\u0440\u0443 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440:<\/p>\n<pre><code class=\"cpp\">void MT::ThreadPool::clear_completed() { std::scoped_lock lock(completed_tasks_mutex, signal_queue_mutex); completed_tasks.clear(); while (!signal_queue.empty()) signal_queue.pop(); }  void MT::ThreadPool::set_logger_flag(bool flag) { logger_flag = flag; }  MT::ThreadPool::~ThreadPool() { stopped = true; tasks_access.notify_all(); for (auto&amp; thread : threads) { thread-&gt;_thread.join(); delete thread; } }<\/code><\/pre>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>ThreadPool::clear_completed()<\/code> \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0436\u0438\u0437\u043d\u0438 \u043f\u0443\u043b\u0430. \u041a\u0430\u043a \u044f \u0438 \u043e\u0431\u0435\u0449\u0430\u043b \u0440\u0430\u043d\u0435\u0435, \u0444\u043b\u0430\u0433 <code>ThreadPool::stopped<\/code> \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f <code>true<\/code>\u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u0443\u043b\u0430. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0442\u0443\u0442 \u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 <code>std::thread::join()<\/code> \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043f\u043e\u0442\u043e\u043a\u043e\u0432.<\/p>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f ThreadPool<\/h2>\n<p>\u0410 \u0432\u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0435\u0433\u043e \u043f\u0443\u043b\u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 3-\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u0414\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u0431\u0443\u0434\u0443\u0442 \u0441\u0438\u0433\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e &#171;\u0440\u0435\u0434\u043a\u043e\u043c \u0443\u0441\u043f\u0435\u0445\u0435&#187; \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043d\u0430 \u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0442\u0440\u0430\u0447\u0435\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438:<\/p>\n<pre><code class=\"cpp\">#include \"thread_pool.h\"  struct TestTask : public MT::Task { int duration; TestTask(const std::string&amp; id, int _duration) : Task(id) { duration = _duration + ((rand() % 20)); description += \"_\" + std::to_string(duration); }; void one_thread_method() override { if (duration &gt;= 10) { send_signal(); return; } else std::this_thread::sleep_for(std::chrono::seconds(duration)); } };  int main() {  MT::ThreadPool thread_pool(3); thread_pool.set_logger_flag(true); \/\/ \u0441\u043d\u0438\u043c\u0430\u0435\u043c \u043f\u0443\u043b \u0441 \u043f\u0430\u0443\u0437\u044b, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u043f\u043e\u0442\u043e\u043a\u0430\u043c \u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0437\u0430 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430\u043b\u0435\u0442\u0443 thread_pool.start(); for (int i = 0; i &lt; 20; i++) { thread_pool.add_task(TestTask(\"TestTask_\" + std::to_string(i + 1), 1)); } \/\/ \u0434\u043e\u0436\u0434\u0435\u043c\u0441\u044f \u0442\u0440\u0435\u0445 \"\u0440\u0435\u0434\u043a\u0438\u0445 \u0443\u0441\u043f\u0435\u0445\u043e\u0432\" for (int i = 0; i &lt; 3; i++) { MT::task_id signal = thread_pool.wait_signal(); if (signal != 0) { auto result = thread_pool.get_result&lt;TestTask&gt;(signal); std::cout &lt;&lt; \"id: \" &lt;&lt; signal &lt;&lt; \", duration: \" &lt;&lt; result-&gt;duration &lt;&lt; std::endl; } }  return 0; }<\/code><\/pre>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0418\u0442\u0430\u043a, \u043c\u043e\u0439 \u043c\u043e\u043d\u043e\u043b\u043e\u0433 \u043f\u043e\u0434\u043e\u0448\u0435\u043b \u043a \u043a\u043e\u043d\u0446\u0443, \u0438 \u043c\u043d\u0435 \u043f\u043e\u0440\u0430 \u0443\u0445\u043e\u0434\u0438\u0442\u044c. \u041f\u043b\u0430\u043d \u0441\u0442\u0430\u0442\u044c\u0438 \u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441\u0447\u0438\u0442\u0430\u044e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u043c\u0438.<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u0441 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f <a href=\"https:\/\/github.com\/Dedulya07\/ThreadPool\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a>. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443 <code>std c++17<\/code>. \u0412\u0441\u0435\u043c \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/738250\/\"> https:\/\/habr.com\/ru\/articles\/738250\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u042f \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e \u0441\u043e\u0437\u0440\u0435\u043b \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0442\u0443\u0442. \u0417\u0430 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0432 \u0441\u0444\u0435\u0440\u0435 IT \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0441\u0432\u043e\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 C++, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e, \u043d\u043e \u0432\u0435\u0440\u043d\u043e \u043e\u0431\u0440\u0430\u0441\u0442\u0430\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c\u0438 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438. \u041d\u0435 \u0432\u0441\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0435 \u0432 \u043d\u0435\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u043c\u043d\u043e\u044e \u0441 \u043d\u0443\u043b\u044f, \u043d\u043e \u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u0442\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043f\u043e\u0434 \u0441\u0432\u043e\u0438 \u043d\u0443\u0436\u0434\u044b. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u043d\u0435\u043f\u0440\u0435\u043e\u0434\u043e\u043b\u0438\u043c\u043e\u0435 \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043c\u043e\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438.<\/p>\n<h2>\u041e \u0447\u0435\u043c \u0438 \u0437\u0430\u0447\u0435\u043c \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f?<\/h2>\n<p>\u042f \u0434\u0430\u0432\u043d\u043e \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u0441\u044f \u0442\u0435\u043c\u043e\u0439 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u043d\u0435\u0439 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u043c\u043e\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445. \u042f \u043d\u0438 \u0432 \u043a\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u044e \u043d\u0430 \u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u0430 \u0432 \u044d\u0442\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438, \u043b\u0438\u0448\u044c \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u044f \u0431\u0443\u0434\u0443 \u0433\u0434\u0435-\u0442\u043e \u043d\u0435\u0442\u043e\u0447\u0435\u043d, \u0442\u043e \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u043d\u044f\u0442\u044c, \u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c. \u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u0433\u0440\u0430\u043c\u043e\u0442\u043d\u043e \u0438 \u0434\u043e\u0445\u043e\u0434\u0447\u0438\u0432\u043e \u043e\u0441\u0432\u0435\u0442\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b:<\/p>\n<ol>\n<li>\n<p>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u0438 \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f?<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043d\u044f\u0442\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0438 \u043f\u043e\u0442\u043e\u043a\u0430 \u0432 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u041a\u0430\u043a \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043c\u0430\u0448\u0438\u043d\u0430?<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043d\u044f\u0442\u0438\u0435 \u043f\u0443\u043b\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 C++.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432 C++.<\/p>\n<\/li>\n<li>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0443\u043b\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 C++.<\/p>\n<\/li>\n<\/ol>\n<p>\u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e, \u0438\u0437\u0443\u0447\u0430\u044f \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c, \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c &#171;\u043e\u0431\u043b\u0430\u0437\u0438\u0442\u044c&#187; \u043a\u0443\u0447\u0443 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0434\u0435\u0441\u044c \u044f \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b \u043f\u0435\u0440\u0435\u0434 \u0441\u043e\u0431\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0443 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u043e\u0435\u0434\u0438\u043d\u043e. \u042f \u043e\u0447\u0435\u043d\u044c \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f, \u0438 \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442 \u043a\u043e\u043c\u0443-\u043d\u0438\u0431\u0443\u0434\u044c \u0436\u0438\u0437\u043d\u044c.<\/p>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0435?<\/h2>\n<p><strong>\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f<\/strong>&nbsp;\u2014 \u044d\u0442\u043e \u0442\u0438\u043f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e&nbsp;\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0438\u043b\u0438&nbsp;\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432. \u0411\u043e\u043b\u044c\u0448\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0447\u0430\u0441\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043c\u0435\u043b\u043a\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0442\u0435\u043c \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u044b \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u0438, \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0448\u0435\u043d\u0430 \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435.<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043e \u0447\u0435\u043c \u0438\u0434\u0435\u0442 \u0440\u0435\u0447\u044c, \u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043a\u0430\u043b\u0430\u043c\u0431\u0443\u0440\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 \u043f\u043e\u0432\u0441\u0435\u0434\u043d\u0435\u0432\u043d\u043e\u0439 \u0436\u0438\u0437\u043d\u0438.<\/p>\n<blockquote>\n<p><em>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0441\u0435\u0431\u044f \u0432&nbsp;\u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u043e\u043c \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0435, \u0441&nbsp;\u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0439 \u0442\u0435\u043b\u0435\u0436\u043a\u043e\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432, \u0441\u0442\u043e\u044f\u0449\u0435\u0433\u043e \u0432&nbsp;\u043d\u0435&nbsp;\u043c\u0435\u043d\u0435\u0435 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043f\u0435\u0440\u0435\u0434 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0439 \u043f\u0440\u043e\u0434\u0430\u0432\u0449\u0438\u0446\u0435\u0439. \u041a\u0430\u0436\u0434\u044b\u0439 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u0442\u043e\u0440\u0430 \u0440\u0430\u0437\u0433\u043d\u0435\u0432\u0430\u043d\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043a\u0430\u0441\u0441\u0443 \u0438 \u043f\u0440\u0438&nbsp;\u044d\u0442\u043e\u043c \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043f\u0440\u0430\u0432 \u0432&nbsp;\u0442\u043e\u043c, \u0447\u0442\u043e&nbsp;\u0437\u0430\u0442\u043e\u0440 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c &#171;\u0440\u0430\u0441\u0441\u043e\u0441\u0435\u0442\u0441\u044f&#187; \u0432&nbsp;\u0434\u0432\u0430 \u0440\u0430\u0437\u0430&nbsp;\u0431\u044b\u0441\u0442\u0440\u0435\u0435.<\/em><\/p>\n<\/blockquote>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044e \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u0434\u0432\u0435\u0440\u0436\u0435\u043d\u044b \u043d\u0435 \u0432\u0441\u0435 \u0437\u0430\u0434\u0430\u0447\u0438. \u0417\u0434\u0435\u0441\u044c \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0430\u0442\u043e\u043c\u0430, \u043a\u0430\u043a \u043d\u0435\u0434\u0435\u043b\u0438\u043c\u043e\u0439 \u0447\u0430\u0441\u0442\u0438\u0446\u044b. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0440\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0430\u0436\u0435 \u0438 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0440\u0435\u0434\u043a\u043e \u0438 \u0437\u0430 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<h2>\u041a\u0430\u043a \u044d\u0442\u043e \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u0432 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435? \u041f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0438 \u043f\u043e\u0442\u043e\u043a\u0438<\/h2>\n<p>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u0431\u044b\u043b\u0430 \u0432\u0437\u044f\u0442\u0430 <a href=\"https:\/\/codernet.ru\/articles\/drugoe\/potok_i_proczessyi_v_operaczionnoj_sisteme_proczessore_i_programmirovanii\/\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a> \u0438 <a href=\"https:\/\/pyatilistnik.org\/difference-between-physical-cores-and-logical-processors\/\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a>. \u041f\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443, \u0434\u043b\u044f \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ul>\n<li>\n<p><strong>\u041f\u0440\u043e\u0446\u0435\u0441\u0441<\/strong> \u043d\u0430 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u2014 \u044d\u0442\u043e \u043b\u044e\u0431\u043e\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0431\u0440\u0430\u0443\u0437\u0435\u0440, \u0430\u043d\u0442\u0438\u0432\u0438\u0440\u0443\u0441\u043d\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, Skype \u0438 \u0434\u0440. \u2014 \u0432\u0441\u0435 \u044d\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u043d\u0430 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430 \u0432 \u0442\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435, \u0447\u0442\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0435\u0442 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u2014 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c \u0438 \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0434\u0438\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e <strong>\u043f\u043e\u0442\u043e\u043a\u043e\u0432 (Threads)<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u0412\u0430\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 \u043a\u043e\u0434\u0430 \u043e\u0434\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0434\u0435\u043b\u044f \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u043e\u0431\u0449\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u044b \u0438\u043c\u0435\u044e\u0442 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u044b, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044f\u0434\u0435\u0440. \u041a\u0430\u0436\u0434\u043e\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u044f\u0434\u0440\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a. \u0420\u0430\u043d\u044c\u0448\u0435 \u0431\u044b\u043b\u043e \u0442\u0430\u043a: \u043e\u0434\u043d\u043e \u044f\u0434\u0440\u043e \u0438\u043c\u0435\u043b\u043e \u043e\u0434\u0438\u043d \u044f\u0434\u0435\u0440\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a, \u0430 \u043e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a \u2014 \u044d\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0434\u0435\u043b\u0430\u0442\u044c \u044f\u0434\u0440\u0430 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u043c\u0438, \u0430 \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043e\u0434\u043d\u043e \u044f\u0434\u0440\u043e \u043c\u043e\u0436\u0435\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u0430\u043d\u0434 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0447\u0438\u0441\u043b\u043e\u043c  <strong>\u044f\u0434\u0435\u0440\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432<\/strong>. \u0413\u0440\u0443\u0431\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0435\u0441\u043b\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u044f\u0434\u0440\u0435 4 \u044f\u0434\u0435\u0440\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u0430, \u0442\u043e \u044f\u0434\u0440\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e 4 \u043a\u043e\u043c\u0430\u043d\u0434\u044b.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043b\u0435\u0433\u043a\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e <strong>\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432 <\/strong>(\u0447\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0447\u0438\u0441\u043b\u0443 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e), \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043d\u0430 \u0432\u0430\u0448\u0435\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435. \u0412 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 Windows 10 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c &#171;\u0414\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440 \u0437\u0430\u0434\u0430\u0447&#187; \u0438 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0432\u043a\u043b\u0430\u0434\u043a\u0443 &#171;\u0426\u041f&#187; \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 &#171;\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c&#187;. \u041d\u0430 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0435 \u043d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043c\u043e\u0435\u0433\u043e \u041f\u041a: 1 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439 6-\u0442\u0438 \u044f\u0434\u0435\u0440\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440, \u043a\u0430\u0436\u0434\u043e\u0435 \u044f\u0434\u0440\u043e \u0438\u043c\u0435\u0435\u0442 \u043f\u043e 2 \u044f\u0434\u0435\u0440\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u0430, \u0438 \u0442\u043e\u0433\u043e \u043c\u043d\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e 12 \u044f\u0434\u0435\u0440\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 (\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432) \u0432\u0441\u0435\u0433\u043e.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043c\u043e\u0435\u0433\u043e \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430.<\/figcaption><\/div>\n<\/figure>\n<p>\u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430, \u043f\u0440\u0438\u0437\u043d\u0430\u044e\u0441\u044c, \u0447\u0442\u043e \u044f \u0432\u0430\u0441 \u043d\u0435\u043c\u043d\u043e\u0436\u043a\u043e \u043e\u0431\u043c\u0430\u043d\u0443\u043b. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0441\u043b\u043e\u0432\u043e <strong><em>&#171;\u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e&#187;<\/em><\/strong> \u0432\u0441\u044e\u0434\u0443 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 <strong><em>&#171;\u0443\u0441\u043b\u043e\u0432\u043d\u043e \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e&#187;<\/em><\/strong>. \u041f\u043e-\u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 &#171;\u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e&#187; \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u044f\u0434\u0440\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u0438 \u043d\u0430 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430.<\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0435\u0449\u0435 \u0440\u0430\u0437 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435. \u0417\u0430\u043f\u0443\u0449\u0435\u043d\u043e 259 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0435\u0442 \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c 1 \u043f\u043e\u0442\u043e\u043a (\u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f). \u041a\u0430\u043a \u0436\u0435 6-\u0442\u0438 \u044f\u0434\u0435\u0440\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u0442\u0430\u043a\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0437\u0430\u0434\u0430\u0447?<\/p>\n<p>\u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043e\u0442\u043e\u043a \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043b\u043e\u0434\u043e\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438. \u042f\u0434\u0440\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 \u0442\u0430\u043a\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u0442\u0440\u043e\u0433\u043e \u043e\u0434\u043d\u0443 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e, \u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u0437\u0430\u0434\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u0443\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c (&#171;\u043d\u0430 \u043f\u0430\u043b\u044c\u0446\u0430\u0445&#187;): \u043a\u0430\u0436\u0434\u043e\u0435 \u044f\u0434\u0440\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 &#171;\u043a\u0443\u0441\u043e\u0447\u0435\u043a&#187; \u0441\u0442\u0440\u043e\u0433\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430, \u0437\u0430\u0442\u0435\u043c &#171;\u0437\u0430\u043c\u043e\u0440\u0430\u0436\u0438\u0432\u0430\u0435\u0442&#187; \u0435\u0433\u043e, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044f \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u0446\u0438\u043a\u043b\u0443. \u0427\u0435\u043b\u043e\u0432\u0435\u043a\u0443 \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u044b \u043c\u043e\u043c\u0435\u043d\u0442\u044b &#171;\u0437\u0430\u043c\u043e\u0440\u043e\u0437\u043a\u0438&#187;, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043e\u0447\u0435\u043d\u044c \u043c\u0430\u043b\u044b (\u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0441\u043b\u0430\u0431\u044b\u0439, \u0442\u043e \u044d\u0444\u0444\u0435\u043a\u0442 &#171;\u0437\u0430\u043c\u043e\u0440\u043e\u0437\u043a\u0438&#187; \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u043f\u043e\u0434\u0442\u043e\u0440\u043c\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0439 \u0438\u043b\u0438 \u0434\u043e\u043b\u0433\u0438\u0445 \u0437\u0430\u0433\u0440\u0443\u0437\u043e\u043a). \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u041e\u0421 \u0443\u043c\u0435\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e, \u0440\u0430\u0441\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u044b \u043f\u0440\u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u043d\u0430 \u0430\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432.<\/p>\n<p>\u042d\u0442\u043e\u0442 \u0444\u0430\u043a\u0442 \u0441\u0442\u043e\u0438\u0442 \u0438\u043c\u0435\u0442\u044c \u0432\u0432\u0438\u0434\u0443, \u0442\u0430\u043a \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0443\u0441\u043a\u043e\u0440\u044f\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u0447\u0438\u0441\u043b\u043e \u0440\u0430\u0437, \u0440\u0430\u0432\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0438\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u0432.<\/p>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Thread Pool?<\/h2>\n<p><strong>\u041f\u0443\u043b \u043f\u043e\u0442\u043e\u043a\u043e\u0432 (Thread Pool)<\/strong> \u2014 \u044d\u0442\u043e \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0445 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430 \u0437\u0430\u0434\u0430\u0447\u0438, \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u043d\u044b\u0435 \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432. \u041c\u0430\u0441\u0441\u0438\u0432 \u0437\u0430\u0434\u0430\u0447 \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 <strong>\u043e\u0447\u0435\u0440\u0435\u0434\u0438 (Task Queue)<\/strong>.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u041b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0443\u043b\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432.<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0443\u043b\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u2014 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c &#171;\u0441\u044b\u0440\u0443\u044e&#187; \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0432 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u0440\u0443\u0434\u043e\u0435\u043c\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447, \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0449\u0438\u0445 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0435 \u043d\u0430 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u043a\u0443\u0441\u043e\u0447\u043a\u0438.<\/p>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u043c \u043b\u043e\u0433\u0438\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b Thread Pool&#8217;\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u0430\u043a\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f <strong>\u0435\u0434\u0438\u043d\u043e\u0436\u0434\u044b<\/strong>. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439:<\/p>\n<blockquote>\n<p>1. \u0412 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0437\u0430\u0434\u0430\u0447 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<p>2. \u041f\u043e\u0434 \u0432\u043d\u043e\u0432\u044c \u043f\u0440\u0438\u0431\u044b\u0432\u0448\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0442\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0441\u0442\u0430\u0435\u0442 \u0435\u0435 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c.<\/p>\n<p>3. \u041f\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0434 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u043f\u043e\u0442\u043e\u043a \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0430\u0435\u0442\u0441\u044f.<\/p>\n<\/blockquote>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u043c \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439:<\/p>\n<blockquote>\n<p>1. \u0412 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0437\u0430\u0434\u0430\u0447 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<p>2. \u0417\u0430\u0434\u043e\u043b\u0433\u043e \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0432\u0441\u0435 \u043f\u043e\u0442\u043e\u043a\u0438, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0435\u0441\u044f \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f. \u0412\u043d\u043e\u0432\u044c \u043f\u0440\u0438\u0431\u044b\u0432\u0448\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0434\u043e\u0441\u0442\u0430\u0435\u0442 \u043b\u044e\u0431\u043e\u0439 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0438\u0437 \u043f\u0443\u043b\u0430 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0435\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c.<\/p>\n<p>3. \u041f\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0434 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u043f\u043e\u0442\u043e\u043a \u0441\u043d\u043e\u0432\u0430 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u0432 \u0440\u0435\u0436\u0438\u043c \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f.<\/p>\n<\/blockquote>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0442 \u0430\u0441\u043f\u0435\u043a\u0442 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0437\u043d\u0430\u043d\u0438\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u044f\u0437\u044b\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0442\u0430\u043a \u043a\u0430\u043a \u0437\u0430\u043f\u0443\u0441\u043a \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0442\u0440\u0443\u0434\u043e\u0435\u043c\u043a\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439.<\/p>\n<h2>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e C++<\/h2>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0443\u043b\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c \u0432\u0430\u0441 \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u044f\u0437\u044b\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f C++, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0442\u0435\u0445 \u0441\u0430\u043c\u044b\u0445 \u044f\u0434\u0435\u0440\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 (\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u044f\u0434\u0440\u0430\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430).<\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u043d\u0430\u043c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441 <code>std::thread<\/code>, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 <code>&lt;thread&gt;<\/code>.<\/p>\n<pre><code class=\"cpp\">#include &lt;iostream&gt; #include &lt;thread&gt; #include &lt;chrono&gt;  void sleep(int duration) { \/\/ simulate expensive operation std::this_thread::sleep_for(std::chrono::seconds(duration)); }  int main() { std::cout &lt;&lt; \"starting first thread...\\n\"; std::thread th1(sleep, 1);  std::cout &lt;&lt; \"starting second thread...\\n\"; std::thread th2(sleep, 2);  std::cout &lt;&lt; \"waiting for threads to finish...\\n\";  th1.join(); std::cout &lt;&lt; \"the first thread finished\\n\";  th2.join(); std::cout &lt;&lt; \"the second thread finished\\n\";  std::cout &lt;&lt; \"done\\n\";  return 0; }<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435, \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442, \u043a\u0430\u043a \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>std::thread<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0435\u0435 \u0432\u044b\u0437\u043e\u0432\u0430. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u0442\u043e\u043a \u0442\u0443\u0442 \u0436\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0435\u043b\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0449\u0435\u0439 \u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b &#171;\u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f&#187; \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e\u0442\u043e\u043a\u0430 (\u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0439 \u0435\u043c\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0438) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>std::thread::join()<\/code>. \u0422\u0430\u043a\u0436\u0435, \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e <code>std::thread::join()<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u043c\u0435\u0442\u043e\u0434 <code>std::thread::detach()<\/code>, \u043d\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0434\u0430\u043d\u043d\u0430\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.<\/p>\n<h2>\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432<\/h2>\n<p>\u0418\u0442\u0430\u043a, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c. \u0410 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0434\u0432\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u0430 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0449\u0438\u0439 \u0440\u0435\u0441\u0443\u0440\u0441?<\/p>\n<pre><code class=\"cpp\">#include &lt;iostream&gt; #include &lt;thread&gt; #include &lt;chrono&gt;  void func(int a) { for (int i = 0; i &lt; 3; i++) { std::cout &lt;&lt; a + i; std::this_thread::sleep_for(std::chrono::seconds(1)); std::cout &lt;&lt; \" \"; } std::cout &lt;&lt; \"\\n\"; }  int main() {  std::thread th1(func, 1); std::thread th2(func, 4);  th1.join(); th2.join();  return 0; }<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u043d\u0435\u0437\u0430\u0434\u0430\u0447\u0430, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437, \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u043e\u0431\u0449\u0435\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u0430 (\u0437\u0434\u0435\u0441\u044c \u043f\u043e\u0442\u043e\u043a \u0432\u044b\u0432\u043e\u0434\u0430 <code>std::cout<\/code>) \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0441\u0442\u0438 \u0441\u0435\u0431\u044f \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e. \u041d\u0435\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043e\u0431\u0449\u0438\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043a \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0431\u043e\u043b\u0435\u0435 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f\u043c (\u043e\u0448\u0438\u0431\u043a\u0438, \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f).<\/p>\n<p>\u0422\u0443\u0442 \u0432 \u0438\u0433\u0440\u0443 \u0432\u0441\u0442\u0443\u043f\u0430\u0435\u0442 <strong>\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432<\/strong>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f\u0437\u044b\u043a C++ \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u0432 \u0432\u0438\u0434\u0435 \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 (\u0448\u0430\u0431\u043b\u043e\u043d <code>std::atomic<\/code>, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0432 <code>&lt;atomic&gt;<\/code>) \u0438 \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u043e\u0432 (\u043a\u043b\u0430\u0441\u0441 <code>std::mutex<\/code>, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0432 <code>&lt;mutex&gt;<\/code>). \u0417\u0430\u0434\u0430\u0447\u0430 \u044d\u0442\u0438\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u2014 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c (\u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e) \u043e\u0431\u0449\u0438\u0435 \u0434\u043b\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0438 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u0434\u0430, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u043f\u043e\u0442\u043e\u043a\u0443 (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0432\u044b\u043c \u0434\u043e\u0431\u0440\u0430\u043b\u0441\u044f \u0434\u043e \u043d\u0438\u0445), \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044f \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c <strong>\u043f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c<\/strong>. \u0422\u0430\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0431\u044a\u0435\u043a\u0442 \u043b\u044e\u0431\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 <code>std::atomic<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u0435\u0434\u0438\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e<\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-348058","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/348058","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=348058"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/348058\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=348058"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=348058"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=348058"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}