{"id":157273,"date":"2013-05-21T10:35:03","date_gmt":"2013-05-21T06:35:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=157273"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=157273","title":{"rendered":"<span class=\"post_title\">\u041e\u0431\u0437\u043e\u0440 java.util.concurrent.*<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0412 \u043f\u043e\u0432\u0441\u0435\u0434\u043d\u0435\u0432\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u0430\u043a\u0435\u0442\u043e\u043c \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 java.util.concurrent. \u0418\u043d\u043e\u0433\u0434\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442\u043d\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e java 1.4.2, \u0433\u0434\u0435 \u043d\u0435\u0442 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430, \u043d\u043e \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u0432\u0435\u0440\u0445\u044a\u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0437\u0430\u0434\u0430\u0447\u0438, \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u0430\u0441\u043a\u0438\u043d\u0443\u0442\u044c \u043c\u043e\u0437\u0433\u0430\u043c\u0438 \u0438 \u043b\u0438\u0431\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434, \u043b\u0438\u0431\u043e \u043f\u043e\u0440\u044b\u0442\u044c\u0441\u044f \u0432 javadoc&#8217;\u0430\u0445 \u0438 \u043d\u0430\u0439\u0442\u0438 \u0447\u0442\u043e-\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0435. \u0421 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043e\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043d\u0435\u0442 \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0440\u0435\u0448\u044c \u0438 \u043f\u0438\u0448\u0435\u0448\u044c, \u0431\u043b\u0430\u0433\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u0443\u043f\u0435\u0440\u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u043d\u0435\u0442. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043c\u0435\u043d\u044c\u0448\u0435 \u043a\u043e\u0434\u0430 \u2014 \u043c\u0435\u043d\u044c\u0448\u0435 \u0431\u0430\u0433\u043e\u0432. \u0422\u0435\u043c \u0431\u043e\u043b\u0435\u0435, \u0447\u0442\u043e \u043d\u0430 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043d\u0438\u043a\u0442\u043e \u0432 \u0437\u0434\u0440\u0430\u0432\u043e\u043c \u0443\u043c\u0435 \u044e\u043d\u0438\u0442 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0435 \u043f\u0438\u0448\u0435\u0442, \u0442.\u043a. \u044d\u0442\u043e \u0443\u0436\u0435 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0432\u044b\u0442\u0435\u043a\u0430\u044e\u0449\u0438\u043c\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f\u043c\u0438.<\/p>\n<p>  \u0427\u0442\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f? \u0412 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u0437\u0430\u043f\u0430\u0440\u043a\u0438 \u0438 deadline&#8217;\u043e\u0432 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e \u043e\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u0432\u0435\u0441\u044c java.util.concurrent. \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0447\u0442\u043e \u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u0438 \u0432\u043f\u0435\u0440\u0435\u0434! \u0422\u0430\u043a, \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e, \u0432 \u043a\u043e\u0434\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f ArrayBlockingQueue, ConcurrentHashMap, AtomicInteger, Collections.synchronizedList(new LinkedList()) \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0441\u0442\u0438. \u0418\u043d\u043e\u0433\u0434\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0435\u0442. \u0412 \u043a\u0430\u043a\u043e\u0439 \u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0448\u044c \u043e\u0441\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0431\u043e\u043b\u0435\u0435 95% \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432 java \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430. \u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438, \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u044b, \u043f\u0435\u0440\u0435\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u043d\u0438\u0435 \u0431\u0430\u0439\u0442\u0438\u043a\u043e\u0432 \u0441 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0435, hibernate, spring \u0438\u043b\u0438 EJB, \u0435\u0449\u0435 \u043a\u0430\u043a\u0430\u044f \u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0438, \u0432\u0443\u0430\u043b\u044f, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0433\u043e\u0442\u043e\u0432\u043e.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0445\u043e\u0442\u044c \u043a\u0430\u043a \u0442\u043e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u043d\u0438\u044f \u0438 \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0432 \u0442\u0435\u043c\u0443, \u043d\u0438\u0436\u0435 \u0438\u0434\u0435\u0442 \u043e\u0431\u0437\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e. \u041f\u0438\u0448\u0443 \u043f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e \u043a\u0430\u043a \u0448\u043f\u0430\u0440\u0433\u0430\u043b\u043a\u0443 \u0434\u043b\u044f \u0441\u0435\u0431\u044f. \u0410 \u0435\u0441\u043b\u0438 \u0435\u0449\u0435 \u043a\u043e\u043c\u0443 \u0441\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u2014 \u0432\u043e\u043e\u0431\u0449\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e. <a name=\"habracut\"><\/a><\/p>\n<h1>\u0414\u043b\u044f \u0437\u0430\u0442\u0440\u0430\u0432\u043a\u0438<\/h1>\n<p>  \u0421\u0440\u0430\u0437\u0443 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0430\u0440\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a. \u041f\u0435\u0440\u0432\u0430\u044f \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043b\u0430\u0432\u0430\u0435\u0442 \u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438. \u0412\u0442\u043e\u0440\u0430\u044f \u0434\u043b\u044f \u00ab\u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0445\u00bb \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435\u0440\u043e\u0432 \u2014 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0442\u0443\u0442 \u043d\u0430\u0439\u0434\u0451\u0442\u0441\u044f \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435.  <\/p>\n<ul>\n<li><a href=\"http:\/\/docs.oracle.com\/javase\/tutorial\/essential\/concurrency\/index.html\">Java Concurrency Tutorials<\/a><\/li>\n<li><a href=\"http:\/\/www.cs.umd.edu\/class\/fall2002\/cmsc433-0201\/lectures\/cpjslides.pdf\">Concurrent Programming in Java by Doug Lea<\/a><\/li>\n<\/ul>\n<h1>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0431 \u0430\u0432\u0442\u043e\u0440\u0435 \u043f\u0430\u043a\u0435\u0442\u0430 java.util.concurrent<\/h1>\n<p>  \u0415\u0441\u043b\u0438 \u043a\u0442\u043e \u0445\u043e\u0442\u044c \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u043b \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 java.util.concurrent, \u043d\u0435 \u043c\u043e\u0433\u043b\u0438 \u043d\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u0432 \u0430\u0432\u0442\u043e\u0440\u0430\u0445 Doug Lea (\u0414\u0430\u0433 \u041b\u0438), \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u043e\u0440\u0430 Oswego (\u041e\u0441\u0443\u0438\u0433\u043e) \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0438\u0442\u0435\u0442\u0430 \u0448\u0442\u0430\u0442\u0430 \u041d\u044c\u044e \u0419\u043e\u0440\u043a. \u0412 \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u0435\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043e\u043a \u043f\u043e\u043f\u0430\u043b\u0438 java <a href=\"http:\/\/gee.cs.oswego.edu\/dl\/classes\/collections\/index.html\">collections<\/a> \u0438 <a href=\"http:\/\/gee.cs.oswego.edu\/dl\/classes\/EDU\/oswego\/cs\/dl\/util\/concurrent\/intro.html\">util.concurrent<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u0442\u043e\u043c \u0438\u043b\u0438 \u0438\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u043e\u0442\u0440\u0430\u0437\u0438\u043b\u0438\u0441\u044c \u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 JDK. \u0422\u0430\u043a\u0436\u0435 \u0438\u043c \u0431\u044b\u043b\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 <a href=\"http:\/\/en.wikipedia.org\/wiki\/Malloc#dlmalloc\">dlmalloc<\/a> \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438. \u0421\u0440\u0435\u0434\u0438 \u043b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u043e\u0442\u043c\u0435\u0442\u0438\u043b\u0430\u0441\u044c \u043a\u043d\u0438\u0433\u0430 \u043f\u043e \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 <a href=\"http:\/\/www.informit.com\/store\/concurrent-programming-in-java-design-principles-and-9780201310092\">Concurrent Programming in Java\u2122: Design Principles and Pattern, 2nd Edition<\/a>. \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0435\u0433\u043e <a href=\"http:\/\/g.oswego.edu\/\">\u0434\u043e\u043c\u0430\u0448\u043d\u0435\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0435<\/a>.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/57d\/237\/064\/57d2370647eb56837d5652db3eecd406.jpg\"\/><br \/>  \u0412\u044b\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435 Doug Lean \u043d\u0430 <a href=\"http:\/\/wiki.jvmlangsummit.com\/2010_Main_Page\">JVM Language Summit<\/a> \u0432 2010 \u0433\u043e\u0434\u0443.<\/p>\n<h1>\u041f\u043e \u0432\u0435\u0440\u0448\u043a\u0430\u043c<\/h1>\n<p>  \u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u0443 \u043c\u043d\u043e\u0433\u0438\u0445 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u043e \u0447\u0443\u0432\u0441\u0442\u0432\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0445\u0430\u043e\u0441\u0430 \u043f\u0440\u0438 \u0431\u0435\u0433\u043b\u043e\u043c \u0432\u0437\u0433\u043b\u044f\u0434\u0435 \u043d\u0430 java.util.concurrent. \u0412 \u043e\u0434\u043d\u043e\u043c \u043f\u0430\u043a\u0435\u0442\u0435 \u043d\u0430\u043c\u0435\u0448\u0430\u043d\u044b \u0440\u0430\u0437\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0441 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0440\u0430\u0437\u043d\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c, \u0447\u0442\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u044f\u0435\u0442 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0447\u0442\u043e \u043a \u0447\u0435\u043c\u0443 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u0438 \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u043c\u043e\u0436\u043d\u043e \u0441\u0445\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b \u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u043f\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0443, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0431\u0435\u0436\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/ff8\/e9d\/719\/ff8e9d719402e1b164febae3fd8c0ff5.png\"\/><\/p>\n<p>  <b>Concurrent Collections<\/b> \u2014 \u043d\u0430\u0431\u043e\u0440 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439, \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0435 \u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0439 \u0441\u0440\u0435\u0434\u0435 \u043d\u0435\u0436\u0435\u043b\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0438\u0437 java.util \u043f\u0430\u043a\u0435\u0442\u0430. \u0412\u043c\u0435\u0441\u0442\u043e \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0432\u0440\u0430\u043f\u043f\u0435\u0440\u0430 Collections.synchronizedList \u0441 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a\u043e \u0432\u0441\u0435\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u043e \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u0436\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e <a href=\"http:\/\/ru.wikipedia.org\/wiki\/%D0%9D%D0%B5%D0%B1%D0%BB%D0%BE%D0%BA%D0%B8%D1%80%D1%83%D1%8E%D1%89%D0%B0%D1%8F_%D1%81%D0%B8%D0%BD%D1%85%D1%80%D0%BE%D0%BD%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D1%8F\">wait-free<\/a> \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c.<\/p>\n<p>  <b>Queues<\/b> \u2014 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u0438 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438. \u041d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0437\u0430\u0442\u043e\u0447\u0435\u043d\u044b \u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0438 \u0440\u0430\u0431\u043e\u0442\u0443 \u0431\u0435\u0437 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u0411\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u00ab\u043f\u0440\u0438\u0442\u043e\u0440\u043c\u043e\u0437\u0438\u0442\u044c\u00bb \u043f\u043e\u0442\u043e\u043a\u0438 \u00abProducer\u00bb \u0438\u043b\u0438 \u00abConsumer\u00bb, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0443\u0441\u0442\u0430 \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u043f\u043e\u043d\u0435\u043d\u0430, \u0438\u043b\u0438 \u0436\u0435 \u043d\u0435\u0442 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0433\u043e \u00abConsumer\u00bb&#8217;a.<\/p>\n<p>  <b>Synchronizers<\/b> \u2014 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0443\u0442\u0438\u043b\u0438\u0442\u044b \u0434\u043b\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u043c\u043e\u0449\u043d\u043e\u0435 \u043e\u0440\u0443\u0436\u0438\u0435 \u0432 \u00ab\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445\u00bb \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u0445.<\/p>\n<p>  <b>Executors<\/b> \u2014 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0435 \u0444\u0440\u0435\u0439\u043c\u043e\u0440\u043a\u0438 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0443\u043b\u043e\u0432 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432. <\/p>\n<p>  <b>Locks<\/b> \u2014 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0438 \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0438\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0431\u0430\u0437\u043e\u0432\u044b\u043c\u0438 synchronized, wait, notify, notifyAll.<\/p>\n<p>  <b>Atomics<\/b> \u2014 \u043a\u043b\u0430\u0441\u0441\u044b \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043d\u0430\u0434 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u0430\u043c\u0438 \u0438 \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438.<\/p>\n<h1>1. Concurrent Collections<\/h1>\n<h4>CopyOnWrite \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438<\/h4>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/324\/0ee\/2cf\/3240ee2cf87d7582e7d721ee7e0be951.png\"\/><\/p>\n<p>  \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u0441\u0430\u043c\u043e \u0437\u0430 \u0441\u0435\u0431\u044f. \u0412\u0441\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 (add, set, remove) \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442 \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043d\u043e\u0432\u043e\u0439 \u043a\u043e\u043f\u0438\u0438 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430. \u0422\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043f\u0440\u0438 \u043f\u0440\u043e\u0445\u043e\u0434\u0435 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c \u043f\u043e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u043d\u0435 \u043a\u0438\u043d\u0435\u0442\u0441\u044f ConcurrentModificationException. \u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0438 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043a\u043e\u043f\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0444\u0435\u0440\u0435\u043d\u0441\u044b (\u0441\u0441\u044b\u043b\u043a\u0438) \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u044b (shallow copy), \u0442.\u0447. \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u043e\u043b\u044f\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0435 thread-safe. CopyOnWrite \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 write \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0440\u0435\u0434\u043a\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 listeners \u0438 \u043f\u0440\u043e\u0445\u043e\u0434\u0430 \u043f\u043e \u043d\u0438\u043c.<\/p>\n<p>  <b>CopyOnWriteArrayList&lt;E&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u041f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u043e\u0433 ArrayList, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441 CopyOnWrite \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c. <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440<\/b><\/p>\n<div class=\"spoiler_text\">\n<table>\n<tr>\n<td>CopyOnWriteArrayList(E[] toCopyIn)<\/td>\n<td>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0439 \u043d\u0430 \u0432\u0445\u043e\u0434 \u043c\u0430\u0441\u0441\u0438\u0432.<\/td>\n<\/tr>\n<tr>\n<td>int indexOf(E e, int index)<\/td>\n<td>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u043f\u043e\u0438\u0441\u043a \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430.<\/td>\n<\/tr>\n<tr>\n<td>int lastIndexOf(E e, int index)<\/td>\n<td>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u043f\u043e\u0438\u0441\u043a\u0435, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430.<\/td>\n<\/tr>\n<tr>\n<td>boolean addIfAbsent(E e)<\/td>\n<td>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u043d\u0435\u0442 \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438. \u0414\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 equals.<\/td>\n<\/tr>\n<tr>\n<td>int addAllAbsent(Collection&lt;? extends E&gt; c)<\/td>\n<td>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div>\n<p>  <b>CopyOnWriteArraySet&lt;E&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 Set, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0430\u044f \u0437\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 CopyOnWriteArrayList. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0438 \u043e\u0442 CopyOnWriteArrayList, \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043d\u0435\u0442.<\/p>\n<h4>Scalable Maps<\/h4>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/5b8\/765\/fe7\/5b8765fe74c096ef78942ba450b82765.png\"\/><\/p>\n<p>  \u0423\u043b\u0443\u0447\u0448\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 HashMap, TreeMap \u0441 \u043b\u0443\u0447\u0448\u0435\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u0438.<\/p>\n<p>  <b>ConcurrentMap&lt;K, V&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/36b\/c31\/fa2\/36bc31fa2bdf7a08f3a85dff79ee4eef.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u044e\u0449\u0438\u0439 Map \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b<\/b><\/p>\n<div class=\"spoiler_text\">\n<table>\n<tr>\n<td>V putIfAbsent(K key, V value)<\/td>\n<td>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u043e\u0432\u0443\u044e \u043f\u0430\u0440\u0443 key-value \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043a\u043b\u044e\u0447\u0430 \u043d\u0435\u0442 \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430.<\/td>\n<\/tr>\n<tr>\n<td>boolean remove(Object key, Object value)<\/td>\n<td>\u0423\u0434\u0430\u043b\u044f\u0435\u0442 key-value \u043f\u0430\u0440\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 Map. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 true, \u0435\u0441\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0431\u044b\u043b \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0443\u0434\u0430\u043b\u0435\u043d.<\/td>\n<\/tr>\n<tr>\n<td>boolean replace(K key, V oldValue, V newValue)<\/td>\n<td>\u0417\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u0442\u0430\u0440\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u043d\u043e\u0432\u043e\u0435 \u043f\u043e \u043a\u043b\u044e\u0447\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0441\u0442\u0430\u0440\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u0432 Map. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 true, \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u043e \u043d\u0430 \u043d\u043e\u0432\u043e\u0435.<\/td>\n<\/tr>\n<tr>\n<td>V replace(K key, V value)<\/td>\n<td>\u0417\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u0442\u0430\u0440\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u043d\u043e\u0432\u043e\u0435 \u043f\u043e \u043a\u043b\u044e\u0447\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043a\u043b\u044e\u0447 \u0430\u0441\u0441\u043e\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043d \u0441 \u043b\u044e\u0431\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430.<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div>\n<p>  <b>ConcurrentHashMap&lt;K, V&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 Hashtable \u0438 \u0431\u043b\u043e\u043a\u043e\u0432 synhronized \u043d\u0430 HashMap, \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0432 \u0432\u0438\u0434\u0435 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u043e\u0432, \u0440\u0430\u0437\u0431\u0438\u0442\u044b\u0445 \u043f\u043e hash&#8217;\u0430\u043c \u043a\u043b\u044e\u0447\u0435\u0439. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u043b\u043e\u0447\u0438\u0442\u0441\u044f \u043f\u043e \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u043c, \u0430 \u043d\u0435 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0443. \u0412 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435, \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0441\u0440\u0435\u0437 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u043d\u0435 \u043a\u0438\u0434\u0430\u044e\u0442 ConcurrentModificationException. \u0411\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e ConcurrentHashMap \u043e\u043f\u0438\u0441\u0430\u043d \u0432 \u0445\u0430\u0431\u0440\u0430\u0442\u043e\u043f\u0438\u043a\u0435 <a href=\"http:\/\/habrahabr.ru\/post\/132884\/\">\u0442\u0443\u0442<\/a>. <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440<\/b><\/p>\n<div class=\"spoiler_text\">\n<table>\n<tr>\n<td>ConcurrentHashMap(int initialCapacity, float loadFactor, int concurrencyLevel)<\/td>\n<td>3-\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u2014 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043f\u0438\u0448\u0443\u0449\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e 16. \u0412\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div>\n<p>  <b>ConcurrentNavigableMap&lt;K,V&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/36b\/c31\/fa2\/36bc31fa2bdf7a08f3a85dff79ee4eef.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/c29\/5ad\/47f\/c295ad47f86291abd7e8fe2b91b9621c.png\"\/><\/b> \u2014 \u0420\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 NavigableMap \u0438 \u0432\u044b\u043d\u0443\u0436\u0434\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c ConcurrentNavigableMap \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0412\u0441\u0435 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0434\u0435\u043a\u043b\u0430\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u0438 \u043d\u0435 \u043a\u0438\u0434\u0430\u044e\u0442 ConcurrentModificationException.<\/p>\n<p>  <b>ConcurrentSkipListMap&lt;K, V&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/c29\/5ad\/47f\/c295ad47f86291abd7e8fe2b91b9621c.png\"\/><\/b> \u2014 \u042f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u043e\u043c TreeMap \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438. \u0414\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043f\u043e \u043a\u043b\u044e\u0447\u0443 \u0438 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0443\u0441\u0440\u0435\u0434\u043d\u0435\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c log(N) \u0434\u043b\u044f containsKey, get, put, remove \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u0445\u043e\u0436\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u0431\u043e\u0442\u044b SkipList \u043e\u043f\u0438\u0441\u0430\u043d \u043d\u0430 <a href=\"http:\/\/ru.wikipedia.org\/wiki\/%D0%A1%D0%BF%D0%B8%D1%81%D0%BE%D0%BA_%D1%81_%D0%BF%D1%80%D0%BE%D0%BF%D1%83%D1%81%D0%BA%D0%B0%D0%BC%D0%B8\">Wiki<\/a> \u0438 <a href=\"http:\/\/habrahabr.ru\/post\/139870\/\">\u0445\u0430\u0431\u0440\u0435<\/a>.<\/p>\n<p>  <b>ConcurrentSkipListSet&lt;E&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/c29\/5ad\/47f\/c295ad47f86291abd7e8fe2b91b9621c.png\"\/><\/b> \u2014 \u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f Set \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 ConcurrentSkipListMap.<\/p>\n<h1>2. Queues<\/h1>\n<p>  <\/p>\n<h4>Non-Blocking Queues<\/h4>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/bc7\/78f\/458\/bc778f4581a3bd53e28ab87c0ca1a0ed.png\"\/><\/p>\n<p>  \u041f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u0438 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Queue \u043d\u0430 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u043d\u043e\u0434\u0430\u0445 (linked nodes). <\/p>\n<p>  <b>ConcurrentLinkedQueue&lt;E&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u0412 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f wait-free \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0442 Michael &#038; Scott, \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 garbage collector&#8217;\u043e\u043c. \u042d\u0442\u043e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d \u0438, \u0447\u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u0432\u0430\u0436\u043d\u043e\u0435, \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440, \u0442.\u043a. \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d \u043d\u0430 <a href=\"http:\/\/en.wikipedia.org\/wiki\/Compare-and-swap\">CAS<\/a>. \u041c\u0435\u0442\u043e\u0434 size() \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0434\u043e\u043b\u0433\u043e, \u0442.\u0447. \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0435\u0433\u043e \u043d\u0435 \u0434\u0435\u0440\u0433\u0430\u0442\u044c. \u0414\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u0443\u0442 <a href=\"http:\/\/www.cs.rochester.edu\/u\/michael\/PODC96.html\">\u0442\u0443\u0442<\/a>.<\/p>\n<p>  <b>ConcurrentLinkedDeque&lt;E&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/968\/b76\/9b1\/968b769b1a83359a83e5fd169d8dbde4.png\"\/><\/b> \u2014 Deque \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a Double ended queue \u0438 \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u00abDeck\u00bb. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438 \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0442\u044c \u0441 \u043e\u0431\u043e\u0438\u0445 \u0441\u0442\u043e\u0440\u043e\u043d. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043e\u0431\u0430 \u0440\u0435\u0436\u0438\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b: FIFO (First In First Out) \u0438 LIFO (Last In First Out). \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435, ConcurrentLinkedDeque \u0441\u0442\u043e\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e, \u0435\u0441\u043b\u0438 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u043e LIFO, \u0442.\u043a. \u0437\u0430 \u0441\u0447\u0435\u0442 \u0434\u0432\u0443\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043d\u043e\u0434 \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043f\u0440\u043e\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442 \u043f\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 40% \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 ConcurrentLinkedQueue.<\/p>\n<h4>Blocking Queues<\/h4>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/009\/d00\/33b\/009d0033b5c6bf14fa31d66cf7ea1980.png\"\/><\/p>\n<p>  <b>BlockingQueue&lt;E&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/36b\/c31\/fa2\/36bc31fa2bdf7a08f3a85dff79ee4eef.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u041f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u044f\u0432\u043d\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f ConcurrentLinkedQueue. \u0415\u0441\u043b\u0438 \u043f\u043e\u0442\u043e\u043a\u0438, \u0440\u0430\u0437\u0433\u0440\u0435\u0431\u0430\u044e\u0449\u0438\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u0443\u0442 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0441 \u043d\u0430\u043f\u043b\u044b\u0432\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0445\u043b\u043e\u043f\u043e\u0442\u0430\u0442\u044c out of memory \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u0438\u0442\u044c IO\/Net \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0443\u043f\u0430\u0434\u0435\u0442 \u0432 \u0440\u0430\u0437\u044b \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u0441\u0442\u0430\u043d\u0435\u0442 \u043e\u0442\u043a\u0430\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u043e \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u0430\u043c \u0438\u043b\u0438 \u0438\u0437 \u0437\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0445 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u043e\u0432 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u0414\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043d\u0443\u0436\u043d\u0430 queue \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u0434\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438\u043b\u0438 \u0441 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430\u043c\u0438 \u043f\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c. \u0422\u0443\u0442 \u0442\u043e \u0438 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 BlockingQueue, \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0434\u043e\u0440\u043e\u0433\u0443 \u043a \u0446\u0435\u043b\u043e\u043c\u0443 \u043d\u0430\u0431\u043e\u0440\u0443 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u041f\u043e\u043c\u0438\u043c\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 queue, \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438\u0441\u044c \u043d\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0430\u0433\u0438\u0440\u0443\u044e\u0442 \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443 \u043d\u0430 \u043d\u0435\u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 queue. \u0422\u0430\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u0443\u044e queue, \u043e\u0434\u0438\u043d \u043c\u0435\u0442\u043e\u0434 \u043a\u0438\u043d\u0435\u0442 IllegalStateException, \u0434\u0440\u0443\u0433\u043e\u0439 \u0432\u0435\u0440\u043d\u0435\u0442 false, \u0442\u0440\u0435\u0442\u0438\u0439 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u0442\u043e\u043a, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u043c\u0435\u0441\u0442\u043e, \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u044b\u0439 \u0436\u0435 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u0442\u043e\u043a \u0441 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u043e\u043c \u0438 \u0432\u0435\u0440\u043d\u0435\u0442 false, \u0435\u0441\u043b\u0438 \u043c\u0435\u0441\u0442\u043e \u0442\u0430\u043a \u0438 \u043d\u0435 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f. \u0422\u0430\u043a\u0436\u0435 \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 null \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0442.\u043a. \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 poll \u043a\u0430\u043a \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u0430. <\/p>\n<p>  <b>ArrayBlockingQueue&lt;E&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u041a\u043b\u0430\u0441\u0441 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043a\u043e\u043b\u044c\u0446\u0435\u0432\u043e\u043c \u0431\u0443\u0444\u0435\u0440\u0435. \u041f\u043e\u043c\u0438\u043c\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u00ab\u0447\u0435\u0441\u0442\u043d\u043e\u0441\u0442\u044c\u044e\u00bb \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a. \u0415\u0441\u043b\u0438 fair=false (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e), \u0442\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043d\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f. \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e \u00ab\u0447\u0435\u0441\u0442\u043d\u043e\u0441\u0442\u0438\u00bb \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 ReentrantLock&#8217;a.<\/p>\n<p>  <b>DelayQueue&lt;E extends Delayed&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043f\u0440\u043e\u0448\u0435\u0441\u0442\u0432\u0438\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0435 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 getDelay \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 Delayed.<\/p>\n<p>  <b>LinkedBlockingQueue&lt;E&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u0411\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0430\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u043d\u043e\u0434\u0430\u0445, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043d\u0430 \u00abtwo lock queue\u00bb \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435: \u043e\u0434\u0438\u043d \u043b\u043e\u043a \u043d\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0434\u0440\u0443\u0433\u043e\u0439 \u043d\u0430 \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430. \u0417\u0430 \u0441\u0447\u0435\u0442 \u0434\u0432\u0443\u0445 \u043b\u043e\u043a\u043e\u0432, \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 ArrayBlockingQueue, \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0443\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043d\u043e \u0438 \u0440\u0430\u0441\u0445\u043e\u0434 \u043f\u0430\u043c\u044f\u0442\u0438 \u0443 \u043d\u0435\u0433\u043e \u0432\u044b\u0448\u0435. \u0420\u0430\u0437\u043c\u0435\u0440 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0440\u0430\u0432\u0435\u043d Integer.MAX_VALUE.<\/p>\n<p>  <b>PriorityBlockingQueue&lt;E&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u042f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0439 \u043e\u0431\u0435\u0440\u0442\u043a\u043e\u0439 \u043d\u0430\u0434 PriorityQueue. \u041f\u0440\u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0435\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043b\u043e\u0433\u0438\u043a\u043e\u0439 Comparator&#8217;\u0430 \u0438\u043b\u0438 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Comparable \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u041f\u0435\u0440\u0432\u044b\u043c \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0441\u0430\u043c\u044b\u0439 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<p>  <b>SynchronousQueue&lt;E&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u042d\u0442\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u043e\u0434\u0438\u043d \u0432\u043e\u0448\u0435\u043b, \u043e\u0434\u0438\u043d \u0432\u044b\u0448\u0435\u043b. \u041a\u0430\u0436\u0434\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u00abProducer\u00bb \u043f\u043e\u0442\u043e\u043a \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u00abConsumer\u00bb \u043f\u043e\u0442\u043e\u043a \u043d\u0435 \u0432\u044b\u0442\u0430\u0449\u0438\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u00abConsumer\u00bb \u0431\u0443\u0434\u0435\u0442 \u0436\u0434\u0430\u0442\u044c \u043f\u043e\u043a\u0430 \u00abProducer\u00bb \u043d\u0435 \u0432\u0441\u0442\u0430\u0432\u0438\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<p>  <b>BlockingDeque&lt;E&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/36b\/c31\/fa2\/36bc31fa2bdf7a08f3a85dff79ee4eef.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/c29\/5ad\/47f\/c295ad47f86291abd7e8fe2b91b9621c.png\"\/><\/b> \u2014 \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0434\u0432\u0443\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u0438. \u0414\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0438 \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0442\u044c \u0441 \u0434\u0432\u0443\u0445 \u0441\u0442\u043e\u0440\u043e\u043d \u043e\u0447\u0435\u0440\u0435\u0434\u0438.<\/p>\n<p>  <b>LinkedBlockingDeque&lt;E&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/c29\/5ad\/47f\/c295ad47f86291abd7e8fe2b91b9621c.png\"\/><\/b> \u2014 \u0414\u0432\u0443\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0430\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u043d\u043e\u0434\u0430\u0445, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043a\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0434\u0432\u0443\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0441 \u043e\u0434\u043d\u0438\u043c \u043b\u043e\u043a\u043e\u043c. \u0420\u0430\u0437\u043c\u0435\u0440 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0440\u0430\u0432\u0435\u043d Integer.MAX_VALUE.<\/p>\n<p>  <b> TransferQueue&lt;E&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/36b\/c31\/fa2\/36bc31fa2bdf7a08f3a85dff79ee4eef.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/968\/b76\/9b1\/968b769b1a83359a83e5fd169d8dbde4.png\"\/><\/b> \u2014 \u0414\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0435\u043d \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u00abProducer\u00bb \u043f\u043e\u0442\u043e\u043a \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u00abConsumer\u00bb \u043d\u0435 \u0432\u044b\u0442\u0430\u0449\u0438\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438. \u0411\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0430\u043a \u0441 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u043e\u043c, \u0442\u0430\u043a \u0438 \u0432\u043e\u0432\u0441\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043e\u0436\u0438\u0434\u0430\u044e\u0449\u0438\u0445 \u00abConsumer\u00bb\u043e\u0432. \u0422\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u043a\u0430\u043a \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445, \u0442\u0430\u043a \u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439.<\/p>\n<p>  <b> LinkedTransferQueue&lt;E&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/968\/b76\/9b1\/968b769b1a83359a83e5fd169d8dbde4.png\"\/><\/b> \u2014 \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f TransferQueue \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 Dual Queues with Slack. \u0410\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <a href=\"http:\/\/en.wikipedia.org\/wiki\/Compare-and-swap\">CAS<\/a> \u0438 <a href=\"http:\/\/grepcode.com\/file\/repository.grepcode.com\/java\/root\/jdk\/openjdk\/7-b147\/sun\/misc\/Unsafe.java#Unsafe.park%28boolean%2Clong%29\">\u043f\u0430\u0440\u043a\u043e\u0432\u043a\u0443<\/a> \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f.<\/p>\n<h1>3. Synchronizers<\/h1>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/632\/495\/7bd\/6324957bdddacafa30f5751a27db917c.png\"\/><\/p>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u043b\u044f \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432.<\/p>\n<p>  <b> Semaphore <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 <a href=\"http:\/\/ru.wikipedia.org\/wiki\/%D0%A1%D0%B5%D0%BC%D0%B0%D1%84%D0%BE%D1%80_(%D0%B8%D0%BD%D1%84%D0%BE%D1%80%D0%BC%D0%B0%D1%82%D0%B8%D0%BA%D0%B0)\">\u0421\u0435\u043c\u0430\u0444\u043e\u0440\u044b<\/a> \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u043c\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438 \u0438\u043b\u0438 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439. \u0414\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0431\u0449\u0435\u043c\u0443 \u0440\u0435\u0441\u0443\u0440\u0441\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430. \u0415\u0441\u043b\u0438 \u043e\u043d \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0443\u043b\u044f, \u0442\u043e \u0434\u043e\u0441\u0442\u0443\u043f \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f, \u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442\u0441\u044f. \u0415\u0441\u043b\u0438 \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0440\u0430\u0432\u0435\u043d \u043d\u0443\u043b\u044e, \u0442\u043e \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043f\u043e\u0442\u043e\u043a \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u043f\u043e\u043a\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u043d\u0435 \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442 \u0440\u0435\u0441\u0443\u0440\u0441. \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438 \u00ab\u0447\u0435\u0441\u0442\u043d\u043e\u0441\u0442\u044c\u00bb \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440. \u0423\u0437\u043a\u0438\u043c \u043c\u0435\u0441\u0442\u043e\u043c \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u0435\u043c\u0430\u0444\u043e\u0440\u043e\u0432 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u0442.\u043a. \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0434\u0431\u0438\u0440\u0430\u0442\u044c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438 \u00ab\u0436\u0435\u043b\u0435\u0437\u0430\u00bb.<\/p>\n<p>  <b> CountDownLatch <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u043f\u043e\u0442\u043e\u043a\u0430\u043c \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0445 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u0430\u0445. \u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043b\u043e\u0433\u0438\u043a\u0443 \u043a\u043b\u0430\u0441\u0441\u0430: \u041f\u043e\u0442\u043e\u043a\u0438, \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440, \u0431\u0443\u0434\u0443\u0442 \u0432\u0438\u0441\u0435\u0442\u044c \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 await (\u0441 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u043e\u043c \u0438\u043b\u0438 \u0431\u0435\u0437), \u043f\u043e\u043a\u0430 \u043f\u043e\u0442\u043e\u043a \u0441 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u043c \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0430 countDown. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u0441\u0447\u0435\u0442\u0447\u0438\u043a count down \u043d\u0430 \u0435\u0434\u0438\u043d\u0438\u0446\u0443. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0440\u0430\u0432\u043d\u044b\u043c \u043d\u0443\u043b\u044e, \u0432\u0441\u0435 \u043e\u0436\u0438\u0434\u0430\u044e\u0449\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u0432 await \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442 \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443, \u0430 \u0432\u0441\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0432\u044b\u0437\u043e\u0432\u044b await \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0431\u0435\u0437 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0439. \u0421\u0447\u0435\u0442\u0447\u0438\u043a count down \u043e\u0434\u043d\u043e\u0440\u0430\u0437\u043e\u0432\u044b\u0439 \u0438 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0431\u0440\u043e\u0448\u0435\u043d \u0432 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435.<\/p>\n<p>  <b> CyclicBarrier <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u041c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432 \u043e\u0434\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0435. \u0411\u0430\u0440\u044c\u0435\u0440 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u0433\u0434\u0430 N-\u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432\u044b\u0437\u043e\u0432\u0443\u0442 \u043c\u0435\u0442\u043e\u0434 await(&#8230;) \u0438 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0442\u0441\u044f. \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0430 \u043e\u0436\u0438\u0434\u0430\u044e\u0449\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u044e\u0442\u0441\u044f. \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0434\u043e \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0438 \u0441\u0431\u0440\u043e\u0441\u0430 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 Runnable \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430.<\/p>\n<p>  <b> Exchanger&lt;V&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f, \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u2014 \u044d\u0442\u043e \u043e\u0431\u043c\u0435\u043d \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f null \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438\u043b\u0438 \u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0430\u043a \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0442\u043e\u0440 \u0434\u0432\u0443\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0442\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 exchange(&#8230;) \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u0442\u043e\u0442 \u0436\u0435 \u043c\u0435\u0442\u043e\u0434 \u043d\u0435 \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0442\u043e\u043a. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442, \u043f\u043e\u0442\u043e\u043a\u0438 \u043e\u0431\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442 \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443.<\/p>\n<p>  <b> Phaser <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/968\/b76\/9b1\/968b769b1a83359a83e5fd169d8dbde4.png\"\/><\/b> \u2014 \u0423\u043b\u0443\u0447\u0448\u0435\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0431\u0430\u0440\u044c\u0435\u0440\u0430 \u0434\u043b\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0432\u043c\u0435\u0449\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b CyclicBarrier \u0438 CountDownLatch, \u0432\u0431\u0438\u0440\u0430\u044f \u0432 \u0441\u0435\u0431\u044f \u0441\u0430\u043c\u043e\u0435 \u043b\u0443\u0447\u0448\u0435\u0435 \u0438\u0437 \u043d\u0438\u0445. \u0422\u0430\u043a, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0436\u0435\u0441\u0442\u043a\u043e \u043d\u0435 \u0437\u0430\u0434\u0430\u043d\u043e \u0438 \u043c\u043e\u0436\u0435\u0442 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f. \u041a\u043b\u0430\u0441\u0441 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438 \u0441\u043e\u043e\u0431\u0449\u0430\u0442\u044c \u043e \u0433\u043e\u0442\u043e\u0432\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0442\u043e\u043a\u0430 \u0431\u0435\u0437 \u0435\u0433\u043e \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438. \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0442\u0438\u0442\u0430\u0442\u044c \u0432 \u0445\u0430\u0431\u0440\u0430\u0442\u043e\u043f\u0438\u043a\u0435 <a href=\"http:\/\/habrahabr.ru\/post\/117185\/\">\u0442\u0443\u0442<\/a>.<\/p>\n<h1>4. Executors<\/h1>\n<p>  \u0412\u043e\u0442 \u043c\u044b \u0438 \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c \u043a \u0441\u0430\u043c\u043e\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043f\u0430\u043a\u0435\u0442\u0430. \u0417\u0434\u0435\u0441\u044c \u0431\u0443\u0434\u0443\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 Future \u0438 Callable \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0438 \u0444\u0430\u0431\u0440\u0438\u043a\u0438 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f thread pools: ThreadPoolExecutor, ScheduledPoolExecutor, ForkJoinPool. \u0414\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0434\u0435\u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 \u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432.<\/p>\n<h4>Future and Callable<\/h4>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/b68\/d1c\/1d0\/b68d1c1d05c8ae15bcc8bb3d5ca09bc9.png\"\/><\/p>\n<p>  <b> Future&lt;V&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/36b\/c31\/fa2\/36bc31fa2bdf7a08f3a85dff79ee4eef.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u0417\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u041a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0437\u0434\u0435\u0441\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 get, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043f\u043e\u0442\u043e\u043a (\u0441 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u043e\u043c \u0438\u043b\u0438 \u0431\u0435\u0437) \u0434\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435. \u0422\u0430\u043a\u0436\u0435, \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u043e\u0442\u043c\u0435\u043d\u044b \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0441\u0442\u0430\u0442\u0443\u0441\u0430. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441 FutureTask.<\/p>\n<p>  <b> RunnableFuture&lt;V&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/36b\/c31\/fa2\/36bc31fa2bdf7a08f3a85dff79ee4eef.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/c29\/5ad\/47f\/c295ad47f86291abd7e8fe2b91b9621c.png\"\/><\/b> \u2014 \u0415\u0441\u043b\u0438 Future \u2014 \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f Client API, \u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 RunnableFuture \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438. \u0423\u0441\u043f\u0435\u0448\u043d\u043e\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 run() \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 get.<\/p>\n<p>  <b> Callable&lt;V&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/36b\/c31\/fa2\/36bc31fa2bdf7a08f3a85dff79ee4eef.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u043e\u0433 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 Runnable \u0434\u043b\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439. \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u043a\u0438\u0434\u0430\u0442\u044c checked exception. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0432\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 run(), \u043c\u043d\u043e\u0433\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b java.util.concurrent \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 \u0435\u0433\u043e \u043d\u0430\u0440\u044f\u0434\u0443 \u0441 Runnable.<\/p>\n<p>  <b> FutureTask&lt;V&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 Future\/RunnableFuture. \u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0432\u0445\u043e\u0434 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432 \u0432 \u0432\u0438\u0434\u0435 Runnable \u0438\u043b\u0438 Callable \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u0421\u0430\u043c \u0436\u0435 \u043a\u043b\u0430\u0441\u0441 FutureTask \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432 worker \u043f\u043e\u0442\u043e\u043a\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0447\u0435\u0440\u0435\u0437 new Thread(task).start(), \u0438\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 ThreadPoolExecutor. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 get(&#8230;).<\/p>\n<p>  <b> Delayed <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/36b\/c31\/fa2\/36bc31fa2bdf7a08f3a85dff79ee4eef.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0447\u0430\u0442\u044c\u0441\u044f \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432 DelayQueue. \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0434\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438.<\/p>\n<p>  <b> ScheduledFuture&lt;V&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/36b\/c31\/fa2\/36bc31fa2bdf7a08f3a85dff79ee4eef.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u041c\u0430\u0440\u043a\u0435\u0440\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e\u0449\u0438\u0439 Future \u0438 Delayed \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b.<\/p>\n<p>  <b> RunnableScheduledFuture&lt;V&gt; <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/36b\/c31\/fa2\/36bc31fa2bdf7a08f3a85dff79ee4eef.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/c29\/5ad\/47f\/c295ad47f86291abd7e8fe2b91b9621c.png\"\/><\/b> \u2014 \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e\u0449\u0438\u0439 RunnableFuture \u0438 ScheduledFuture. \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u043e\u0434\u043d\u043e\u0440\u0430\u0437\u043e\u0432\u043e\u0439 \u0438\u043b\u0438 \u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<h4>Executor Services<\/h4>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/e0c\/38d\/f25\/e0c38df25d2fd1d705976554c6452cb4.png\"\/><\/p>\n<p>  <b> Executor <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/36b\/c31\/fa2\/36bc31fa2bdf7a08f3a85dff79ee4eef.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0445 \u0437\u0430\u043f\u0443\u0441\u043a Runnable \u0437\u0430\u0434\u0430\u0447. \u0422\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0432\u044f\u0437\u043a\u0430 \u043c\u0435\u0436\u0434\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0435\u0451 \u0437\u0430\u043f\u0443\u0441\u043a\u0430.<\/p>\n<p>  <b> ExecutorService <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/36b\/c31\/fa2\/36bc31fa2bdf7a08f3a85dff79ee4eef.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 Runnable \u0438\u043b\u0438 Callable \u0437\u0430\u0434\u0430\u0447. \u041c\u0435\u0442\u043e\u0434\u044b submit \u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 \u0432\u0438\u0434\u0435 Callable \u0438\u043b\u0438 Runnable, \u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0434\u0435\u0442 Future, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u041c\u0435\u0442\u043e\u0434\u044b invokeAll \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u0430\u043c\u0438 \u0437\u0430\u0434\u0430\u0447 \u0441 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u043e\u0439 \u043f\u043e\u0442\u043e\u043a\u0430 \u0434\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0437\u0430\u0434\u0430\u0447 \u0432 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435 \u0438\u043b\u0438 \u0434\u043e \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u0430. \u041c\u0435\u0442\u043e\u0434\u044b invokeAny \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043f\u043e\u0442\u043e\u043a \u0434\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u043b\u044e\u0431\u043e\u0439 \u0438\u0437 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447. \u0412 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a\u043e \u0432\u0441\u0435\u043c\u0443, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f graceful shutdown. \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 shutdown, \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438, \u043a\u0438\u0434\u0430\u044f RejectedExecutionException \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0437\u0430\u043a\u0438\u043d\u0443\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 \u0441\u0435\u0440\u0432\u0438\u0441.<\/p>\n<p>  <b> ScheduledExecutorService <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/36b\/c31\/fa2\/36bc31fa2bdf7a08f3a85dff79ee4eef.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u0412 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a \u043c\u0435\u0442\u043e\u0434\u0430\u043c ExecutorService, \u0434\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<p>  <b> AbstractExecutorService <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/93e\/530\/ead\/93e530ead57ae1e70e6d067602e05095.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f ExecutorService&#8217;a. \u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 submit, invokeAll, invokeAny. \u041e\u0442 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f ThreadPoolExecutor, ScheduledThreadPoolExecutor \u0438 ForkJoinPool.<\/p>\n<h4>ThreadPoolExecutor &#038; Factory<\/h4>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/125\/385\/1e3\/1253851e3b0952109c8282990ad9dbab.png\"\/><\/p>\n<p>  <b> Executors <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/576\/c72\/d73576c72fd0c51fe4fffbda47fd2791.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u041a\u043b\u0430\u0441\u0441-\u0444\u0430\u0431\u0440\u0438\u043a\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f ThreadPoolExecutor, ScheduledThreadPoolExecutor. \u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u044d\u0442\u0438\u0445 \u043f\u0443\u043b\u043e\u0432, \u044d\u0442\u0430 \u0444\u0430\u0431\u0440\u0438\u043a\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e. \u0422\u0430\u043a\u0436\u0435, \u0442\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u0440\u0430\u0437\u043d\u044b\u0435 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u044b Runnable-Callable, PrivilegedAction-Callable, PrivilegedExceptionAction-Callable \u0438 \u0434\u0440\u0443\u0433\u0438\u0435.<\/p>\n<p>  <b> ThreadPoolExecutor <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u041e\u0447\u0435\u043d\u044c \u043c\u043e\u0449\u043d\u044b\u0439 \u0438 \u0432\u0430\u0436\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u0432 \u043f\u0443\u043b\u0435 \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u0422\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0432\u0435\u0440\u0445\u044d\u0434 \u043d\u0430 \u043f\u043e\u0434\u043d\u044f\u0442\u0438\u0435 \u0438 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u0410 \u0437\u0430 \u0441\u0447\u0435\u0442 \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432 \u043f\u0443\u043b\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041a\u0430\u043a \u0431\u044b\u043b\u043e \u0440\u0430\u043d\u0435\u0435 \u0441\u043a\u0430\u0437\u0430\u043d\u043e, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0443\u043b \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043e\u0434\u0438\u043d \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0444\u0430\u0431\u0440\u0438\u043a\u0438 Executors. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0442\u043e \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b \u0438\u043b\u0438 \u0441\u0435\u0442\u0442\u0435\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0432\u0441\u0435 \u043e\u0441\u043d\u043e\u0432\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u0443\u043b\u0430. \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0432 \u044d\u0442\u043e\u043c <a href=\"http:\/\/habrahabr.ru\/post\/116363\/\">\u0442\u043e\u043f\u0438\u043a\u0435<\/a>.<\/p>\n<p>  <b> ScheduledThreadPoolExecutor <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u0412 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a \u043c\u0435\u0442\u043e\u0434\u0430\u043c ThreadPoolExecutor, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u043e\u0441\u043b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u043d\u043e\u0441\u0442\u044c\u044e, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0431\u0430\u0437\u0435 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 Timer Service.<\/p>\n<p>  <b> ThreadFactory <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/36b\/c31\/fa2\/36bc31fa2bdf7a08f3a85dff79ee4eef.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, ThreadPoolExecutor \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u0443\u044e \u0447\u0435\u0440\u0435\u0437 Executors.defaultThreadFactory(). \u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0430 \u0438\u043b\u0438 \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u0442\u043e\u043a\u0430, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u044d\u0442\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0435\u0433\u043e \u0432 ThreadPoolExecutor.<\/p>\n<p>  <b> RejectedExecutionHandler <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/36b\/c31\/fa2\/36bc31fa2bdf7a08f3a85dff79ee4eef.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e \u043a\u0430\u043a\u0438\u043c \u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b \u0447\u0435\u0440\u0435\u0437 ThreadPoolExecutor. \u0422\u0430\u043a\u043e\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0442\u0438, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u0442 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0438\u043b\u0438 \u0441\u0435\u0440\u0432\u0438\u0441 \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0438\u043b\u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d (shutdown). \u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0439 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 ThreadPoolExecutor: CallerRunsPolicy \u2014 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u043c \u043f\u043e\u0442\u043e\u043a\u0435; AbortPolicy \u2014 \u043a\u0438\u0434\u0430\u0435\u0442 \u044d\u043a\u0441\u0446\u0435\u043f\u0448\u0435\u043d; DiscardPolicy \u2014 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0443; DiscardOldestPolicy \u2014 \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0441\u0430\u043c\u0443\u044e \u0441\u0442\u0430\u0440\u0443\u044e \u043d\u0435\u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0437\u0430\u0442\u0435\u043c \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0435\u0449\u0435 \u0440\u0430\u0437.<\/p>\n<h4>Fork Join<\/h4>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/442\/afd\/335\/442afd335b6fc6bf036109c65c4821c5.png\"\/><\/p>\n<p>  \u0412 java 1.7 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043d\u043e\u0432\u044b\u0439 Fork Join \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0445 \u043f\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c <a href=\"http:\/\/en.wikipedia.org\/wiki\/Divide_and_conquer_algorithm\">\u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0439 \u0438 \u0432\u043b\u0430\u0432\u0441\u0442\u0432\u0443\u0439<\/a> \u0438\u043b\u0438 <a href=\"http:\/\/ru.wikipedia.org\/wiki\/MapReduce\">Map Reduce<\/a>. \u0427\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u0435\u0439, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 quicksort:<br \/>  <a href=\"http:\/\/en.wikipedia.org\/wiki\/Quicksort\"><img decoding=\"async\" src=\"http:\/\/upload.wikimedia.org\/wikipedia\/commons\/6\/6a\/Sorting_quicksort_anim.gif\"\/><\/a><br \/>  \u0422\u0430\u043a, \u0437\u0430 \u0441\u0447\u0435\u0442 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u043d\u0430 \u0447\u0430\u0441\u0442\u0438, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0438\u0445 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u0430\u0445. \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 ThreadPoolExecutor, \u043d\u043e \u0437\u0430 \u0441\u0447\u0435\u0442 \u0447\u0430\u0441\u0442\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0435 \u044d\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0422\u0443\u0442 \u0442\u043e \u043d\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c Fork Join framework \u0432 \u043e\u0441\u043d\u043e\u0432\u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <a href=\"http:\/\/classes.engineering.wustl.edu\/cse566s\/presentations\/WorkStealing.pdf\">work-stealing<\/a> \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c. \u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0441\u0435\u0431\u044f \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0432 \u0431\u043b\u043e\u0433\u0435 <a href=\"http:\/\/www.igvita.com\/2012\/02\/29\/work-stealing-and-recursive-partitioning-with-fork-join\/\">\u0442\u0443\u0442<\/a> \u0438\u043b\u0438 <a href=\"http:\/\/gee.cs.oswego.edu\/dl\/papers\/fj.pdf\">\u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438<\/a> Doug Lea. \u041f\u0440\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"http:\/\/letitcrash.com\/post\/17607272336\/scalability-of-fork-join-pool\">\u0442\u0443\u0442<\/a>.<\/p>\n<p>  <b> ForkJoinPool <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/968\/b76\/9b1\/968b769b1a83359a83e5fd169d8dbde4.png\"\/><\/b> \u2014 \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0442\u043e\u0447\u043a\u0443 \u0432\u0445\u043e\u0434\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u043e\u0440\u043d\u0435\u0432\u044b\u0445 (main) ForkJoinTask \u0437\u0430\u0434\u0430\u0447. \u041f\u043e\u0434\u0437\u0430\u0434\u0430\u0447\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434\u044b \u0437\u0430\u0434\u0430\u0447\u0438, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0441\u0442\u0440\u0435\u043b\u0438\u0442\u044c\u0441\u044f (fork). \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0443\u043b \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0441 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0440\u0430\u0432\u043d\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0434\u043b\u044f JVM \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432 (cores).<\/p>\n<p>  <b> ForkJoinTask <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/93e\/530\/ead\/93e530ead57ae1e70e6d067602e05095.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/968\/b76\/9b1\/968b769b1a83359a83e5fd169d8dbde4.png\"\/><\/b> \u2014 \u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 Fork Join \u0437\u0430\u0434\u0430\u0447. \u0418\u0437 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c: fork() \u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 ForkJoinWorkerThread \u0434\u043b\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f; invoke() \u2014 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043f\u043e\u0442\u043e\u043a\u0435; join() \u2014 \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0437\u0430\u0434\u0430\u0447\u0438 \u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430; invokeAll(&#8230;) \u2014 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u0432\u0441\u0435 \u0442\u0440\u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044f \u0434\u0432\u0435 \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0437\u0430\u0434\u0430\u0447 \u0437\u0430 \u043e\u0434\u0438\u043d \u0437\u0430\u0445\u043e\u0434; adapt(&#8230;) \u2014 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 ForkJoinTask \u0438\u0437 Runnable \u0438\u043b\u0438 Callable \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432.<\/p>\n<p>  <b> RecursiveTask <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/93e\/530\/ead\/93e530ead57ae1e70e6d067602e05095.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/968\/b76\/9b1\/968b769b1a83359a83e5fd169d8dbde4.png\"\/><\/b> \u2014 \u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043e\u0442 ForkJoinTask, \u0441 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u0430 compute, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0432 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0435.<\/p>\n<p>  <b> RecursiveAction <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/93e\/530\/ead\/93e530ead57ae1e70e6d067602e05095.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/968\/b76\/9b1\/968b769b1a83359a83e5fd169d8dbde4.png\"\/><\/b> \u2014 \u041e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 RecursiveTask \u0442\u0435\u043c, \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/p>\n<p>  <b> ForkJoinWorkerThread <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/968\/b76\/9b1\/968b769b1a83359a83e5fd169d8dbde4.png\"\/><\/b> \u2014 \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 ForkJoinPoll. \u041f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f worker \u043f\u043e\u0442\u043e\u043a\u0430. <\/p>\n<h4>Completion Service<\/h4>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d26\/de6\/de1\/d26de6de112cf6e1b8475162e54016c4.png\"\/><\/p>\n<p>  <b> CompletionService <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/36b\/c31\/fa2\/36bc31fa2bdf7a08f3a85dff79ee4eef.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0441 \u0440\u0430\u0437\u0432\u044f\u0437\u043a\u043e\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432. \u0422\u0430\u043a, \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u044b submit, \u0430 \u0434\u043b\u044f \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 <i>\u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u044b\u0445<\/i> \u0437\u0430\u0434\u0430\u0447 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 take \u0438 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0439 poll. <\/p>\n<p>  <b> ExecutorCompletionService <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u041f\u043e \u0441\u0443\u0442\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0440\u0430\u043f\u043f\u0435\u0440\u043e\u043c \u043d\u0430\u0434 \u043b\u044e\u0431\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Executor, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 ThreadPoolExecutor \u0438\u043b\u0438 ForkJoinPool. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0437\u0430\u0434\u0430\u0447 \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0437\u0430 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c. \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u2014 \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0435\u043c \u0438\u0445, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u2014 \u0436\u0434\u0435\u043c \u0432 take \u043f\u043e\u043a\u0430 \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043d\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044f. \u0412 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f LinkedBlockingQueue, \u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u0430 \u0438 \u043b\u044e\u0431\u0430\u044f \u0434\u0440\u0443\u0433\u0430\u044f \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f BlockingQueue.<\/p>\n<h1>5. Locks<\/h1>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/4f1\/edf\/0f8\/4f1edf0f8640f54475bf37ff72d04895.png\"\/><\/p>\n<p>  <b> Condition <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/36b\/c31\/fa2\/36bc31fa2bdf7a08f3a85dff79ee4eef.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u043d\u044b\u043c wait\/notify\/notifyAll. \u041e\u0431\u044a\u0435\u043a\u0442 \u0441 \u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u043b\u043e\u043a\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 lock.newCondition(). \u0422\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442\u043e\u0432 wait\/notify \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<p>  <b> Lock <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/36b\/c31\/fa2\/36bc31fa2bdf7a08f3a85dff79ee4eef.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0438\u0437 lock framework, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\/\u0431\u043b\u043e\u043a\u0430\u043c \u043d\u0435\u0436\u0435\u043b\u0438 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 synchronized. \u0422\u0430\u043a, \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043b\u043e\u043a\u043e\u0432, \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0438\u0445 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439. \u041f\u043b\u044e\u0441 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0439\u0442\u0438 \u043f\u043e \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u043e\u043c\u0443 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044e, \u0435\u0441\u043b\u0438 \u043b\u043e\u043a \u0443\u0436\u0435 \u043a\u0435\u043c \u0442\u043e \u0437\u0430\u0445\u0432\u0430\u0447\u0435\u043d.<\/p>\n<p>  <b> ReentrantLock <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u041b\u043e\u043a \u043d\u0430 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435. \u0422\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0439\u0442\u0438 \u0432 \u0437\u0430\u0449\u0438\u0449\u0435\u043d\u043d\u044b\u0439 \u0431\u043b\u043e\u043a. \u041a\u043b\u0430\u0441\u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u00ab\u0447\u0435\u0441\u0442\u043d\u0443\u044e\u00bb (fair) \u0438 \u00ab\u043d\u0435\u0447\u0435\u0441\u0442\u043d\u0443\u044e\u00bb (non-fair) \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0443 \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u041f\u0440\u0438 \u00ab\u0447\u0435\u0441\u0442\u043d\u043e\u0439\u00bb \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0435 \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0445 lock(). \u041f\u0440\u0438 \u00ab\u043d\u0435\u0447\u0435\u0441\u0442\u043d\u043e\u0439\u00bb \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0435 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043d\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u043d\u043e, \u043a\u0430\u043a \u0431\u043e\u043d\u0443\u0441, \u0442\u0430\u043a\u0430\u044f \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u00ab\u043d\u0435\u0447\u0435\u0441\u0442\u043d\u0430\u044f\u00bb \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430.<\/p>\n<p>  <b> ReadWriteLock <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/36b\/c31\/fa2\/36bc31fa2bdf7a08f3a85dff79ee4eef.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f read\/write \u043b\u043e\u043a\u043e\u0432. \u0422\u0430\u043a\u0438\u0435 \u043b\u043e\u043a\u0438 \u043d\u0435\u043e\u0431\u044b\u0447\u0430\u0439\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043c\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u043c\u0430\u043b\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0437\u0430\u043f\u0438\u0441\u0438.<\/p>\n<p>  <b> ReentrantReadWriteLock <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u041e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u0445 \u0438 \u043a\u0435\u0448\u0430\u0445, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044f \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0431\u043b\u043e\u043a\u0430\u043c\u0438 synchronized. \u041f\u043e \u0441\u0443\u0442\u0438, \u043a\u043b\u0430\u0441\u0441 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 2-\u0445 \u0432\u0437\u0430\u0438\u043c\u043e\u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0445 \u0440\u0435\u0436\u0438\u043c\u0430\u0445: \u043c\u043d\u043e\u0433\u043e reader&#8217;\u043e\u0432 \u0447\u0438\u0442\u0430\u044e\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c \u0438 \u043a\u043e\u0433\u0434\u0430 \u0442\u043e\u043b\u044c\u043a\u043e 1 writer \u043f\u0438\u0448\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435. <\/p>\n<p>  <b> ReentrantReadWriteLock.ReadLock <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 Read lock \u0434\u043b\u044f reader&#8217;\u043e\u0432, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0439 \u0447\u0435\u0440\u0435\u0437 readWriteLock.readLock().<\/p>\n<p>  <b> ReentrantReadWriteLock.WriteLock <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 Write lock \u0434\u043b\u044f writer&#8217;\u043e\u0432, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0439 \u0447\u0435\u0440\u0435\u0437 readWriteLock.writeLock().<\/p>\n<p>  <b> LockSupport <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u041f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441 \u043b\u043e\u043a\u0430\u043c\u0438. \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u043f\u0430\u0440\u043a\u043e\u0432\u043a\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432\u043c\u0435\u0441\u0442\u043e \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 Thread.suspend() \u0438 Thread.resume().<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/928\/8f8\/e77\/9288f8e777b62ff96c4c953471e27f60.png\"\/><\/p>\n<p>  <b> AbstractOwnableSynchronizer <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/c29\/5ad\/47f\/c295ad47f86291abd7e8fe2b91b9621c.png\"\/><\/b> \u2014 \u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432 \u0441\u0438\u0445\u043d\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438. \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0443 \u043f\u0430\u0440\u0443 \u0433\u0435\u0442\u0442\u0435\u0440\/\u0441\u0435\u0442\u0442\u0435\u0440 \u0434\u043b\u044f \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u044f \u0438 \u0447\u0442\u0435\u043d\u0438\u044f \u044d\u043a\u0441\u043a\u043b\u044e\u0437\u0438\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<p>  <b> AbstractQueuedSynchronizer <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u043b\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 FutureTask, CountDownLatch, Semaphore, ReentrantLock, ReentrantReadWriteLock. \u041c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043d\u043e\u0432\u044b\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438, \u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u043d\u0430 \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u043e\u0435 \u0438 \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 int.<\/p>\n<p>  <b> AbstractQueuedLongSynchronizer <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/c29\/5ad\/47f\/c295ad47f86291abd7e8fe2b91b9621c.png\"\/><\/b> \u2014 \u0420\u0430\u0437\u043d\u043e\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u044c AbstractQueuedSynchronizer, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 long.<\/p>\n<h1>6. Atomics<\/h1>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/5be\/563\/489\/5be563489a039bcb4033edecd3ed0cca.png\"\/><\/p>\n<p>  <b> AtomicBoolean<\/b>, <b>AtomicInteger<\/b>, <b>AtomicLong<\/b>, <b>AtomicIntegerArray<\/b>, <b>AtomicLongArray <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u0427\u0442\u043e \u0435\u0441\u043b\u0438 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0434\u043d\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0442\u0438\u043f\u0430 int? \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0441 synchronized, \u0430 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 set\/get, \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u0438 volatile. \u041d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u0435\u0449\u0435 \u043b\u0443\u0447\u0448\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432 \u043d\u043e\u0432\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b Atomic*. \u0417\u0430 \u0441\u0447\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f <a href=\"http:\/\/en.wikipedia.org\/wiki\/Compare-and-swap\">CAS<\/a>, \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u044d\u0442\u0438\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c \u0435\u0441\u043b\u0438 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 synchronized\/volatile. \u041f\u043b\u044e\u0441 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u0443\u044e \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\/\u0434\u0435\u043a\u0440\u0435\u043c\u0435\u043d\u0442.<\/p>\n<p>  <b> AtomicReference <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u041a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u0441 \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442.<\/p>\n<p>  <b> AtomicMarkableReference <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u041a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043f\u0430\u0440\u043e\u0439 \u043f\u043e\u043b\u0435\u0439: \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u0431\u0438\u0442\u043e\u0432\u044b\u0439 \u0444\u043b\u0430\u0433 (true\/false).<\/p>\n<p>  <b> AtomicStampedReference <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u041a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043f\u0430\u0440\u043e\u0439 \u043f\u043e\u043b\u0435\u0439: \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 int \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>  <b> AtomicReferenceArray <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u041c\u0430\u0441\u0441\u0438\u0432 \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c\u0441\u044f.<\/p>\n<p>  <b> AtomicIntegerFieldUpdater<\/b>, <b>AtomicLongFieldUpdater<\/b>,<b>AtomicReferenceFieldUpdater <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0fb\/43e\/259\/0fb43e259847760ecf54027457005e30.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d73\/4a3\/deb\/d734a3deb05965b8207c68b307cadba8.png\"\/><\/b> \u2014 \u041a\u043b\u0430\u0441\u0441\u044b \u0434\u043b\u044f \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u043e\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u043f\u043e \u0438\u0445 \u0438\u043c\u0435\u043d\u0430\u043c \u0447\u0435\u0440\u0435\u0437 reflection. \u0421\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0435\u0439 \u0434\u043b\u044f CAS \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u0438 \u043a\u0435\u0448\u0438\u0440\u0443\u044e\u0442\u0441\u044f, \u0442.\u0447. \u0442\u0443\u0442 \u043d\u0435\u0442 \u0441\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0430\u0434\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u0437 \u0437\u0430 reflection.<\/p>\n<h1>\u0412\u043c\u0435\u0441\u0442\u043e \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/h1>\n<p>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e, \u0447\u0442\u043e \u0434\u043e\u0447\u0438\u0442\u0430\u043b\u0438 \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u0438\u043b\u0438, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u043f\u0440\u043e\u043b\u0438\u0441\u0442\u043d\u0443\u043b\u0438 \u0441\u0442\u0430\u0442\u044c\u044e \u0432 \u043a\u043e\u043d\u0435\u0446. \u0421\u0440\u0430\u0437\u0443 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0447\u0435\u0440\u043d\u0443\u0442\u044c, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445 \u043b\u0438\u0431\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0433\u0440\u043e\u043c\u043e\u0436\u0434\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e \u0447\u0440\u0435\u0437\u043c\u0435\u0440\u043d\u044b\u043c\u0438 \u0432\u0441\u0442\u0430\u0432\u043a\u0430\u043c\u0438 \u043a\u043e\u0434\u0430. \u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043c\u044b\u0441\u043b\u044c: \u0434\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043e\u0431\u0437\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0437\u043d\u0430\u0442\u044c \u0432 \u043a\u0430\u043a\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0438 \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0438\u043b\u0438 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u0445 \u0441\u0430\u043c\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0441\u0442 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0439 \u0440\u0435\u0448\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e.    \t \t\t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/company\/luxoft\/blog\/157273\/\"> http:\/\/habrahabr.ru\/company\/luxoft\/blog\/157273\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0412 \u043f\u043e\u0432\u0441\u0435\u0434\u043d\u0435\u0432\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u0430\u043a\u0435\u0442\u043e\u043c \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 java.util.concurrent. \u0418\u043d\u043e\u0433\u0434\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442\u043d\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e java 1.4.2, \u0433\u0434\u0435 \u043d\u0435\u0442 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430, \u043d\u043e \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u0432\u0435\u0440\u0445\u044a\u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0437\u0430\u0434\u0430\u0447\u0438, \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u0430\u0441\u043a\u0438\u043d\u0443\u0442\u044c \u043c\u043e\u0437\u0433\u0430\u043c\u0438 \u0438 \u043b\u0438\u0431\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434, \u043b\u0438\u0431\u043e \u043f\u043e\u0440\u044b\u0442\u044c\u0441\u044f \u0432 javadoc&#8217;\u0430\u0445 \u0438 \u043d\u0430\u0439\u0442\u0438 \u0447\u0442\u043e-\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0435. \u0421 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043e\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043d\u0435\u0442 \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0440\u0435\u0448\u044c \u0438 \u043f\u0438\u0448\u0435\u0448\u044c, \u0431\u043b\u0430\u0433\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u0443\u043f\u0435\u0440\u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u043d\u0435\u0442. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043c\u0435\u043d\u044c\u0448\u0435 \u043a\u043e\u0434\u0430 \u2014 \u043c\u0435\u043d\u044c\u0448\u0435 \u0431\u0430\u0433\u043e\u0432. \u0422\u0435\u043c \u0431\u043e\u043b\u0435\u0435, \u0447\u0442\u043e \u043d\u0430 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043d\u0438\u043a\u0442\u043e \u0432 \u0437\u0434\u0440\u0430\u0432\u043e\u043c \u0443\u043c\u0435 \u044e\u043d\u0438\u0442 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0435 \u043f\u0438\u0448\u0435\u0442, \u0442.\u043a. \u044d\u0442\u043e \u0443\u0436\u0435 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0432\u044b\u0442\u0435\u043a\u0430\u044e\u0449\u0438\u043c\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f\u043c\u0438.<\/p>\n<p>  \u0427\u0442\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f? \u0412 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u0437\u0430\u043f\u0430\u0440\u043a\u0438 \u0438 deadline&#8217;\u043e\u0432 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e \u043e\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u0432\u0435\u0441\u044c java.util.concurrent. \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0447\u0442\u043e \u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u0438 \u0432\u043f\u0435\u0440\u0435\u0434! \u0422\u0430\u043a, \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e, \u0432 \u043a\u043e\u0434\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f ArrayBlockingQueue, ConcurrentHashMap, AtomicInteger, Collections.synchronizedList(new LinkedList()) \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0441\u0442\u0438. \u0418\u043d\u043e\u0433\u0434\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0435\u0442. \u0412 \u043a\u0430\u043a\u043e\u0439 \u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0448\u044c \u043e\u0441\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0431\u043e\u043b\u0435\u0435 95% \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432 java \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430. \u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438, \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u044b, \u043f\u0435\u0440\u0435\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u043d\u0438\u0435 \u0431\u0430\u0439\u0442\u0438\u043a\u043e\u0432 \u0441 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0435, hibernate, spring \u0438\u043b\u0438 EJB, \u0435\u0449\u0435 \u043a\u0430\u043a\u0430\u044f \u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0438, \u0432\u0443\u0430\u043b\u044f, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0433\u043e\u0442\u043e\u0432\u043e.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0445\u043e\u0442\u044c \u043a\u0430\u043a \u0442\u043e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u043d\u0438\u044f \u0438 \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0432 \u0442\u0435\u043c\u0443, \u043d\u0438\u0436\u0435 \u0438\u0434\u0435\u0442 \u043e\u0431\u0437\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e. \u041f\u0438\u0448\u0443 \u043f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e \u043a\u0430\u043a \u0448\u043f\u0430\u0440\u0433\u0430\u043b\u043a\u0443 \u0434\u043b\u044f \u0441\u0435\u0431\u044f. \u0410 \u0435\u0441\u043b\u0438 \u0435\u0449\u0435 \u043a\u043e\u043c\u0443 \u0441\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u2014 \u0432\u043e\u043e\u0431\u0449\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e. <\/p>\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-157273","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/157273","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=157273"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/157273\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=157273"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=157273"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=157273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}