{"id":927,"date":"2025-11-26T07:45:24","date_gmt":"2025-11-26T07:45:24","guid":{"rendered":"https:\/\/nurlandroid.com\/?p=927"},"modified":"2025-11-26T07:45:25","modified_gmt":"2025-11-26T07:45:25","slug":"%d0%be%d1%81%d0%bd%d0%be%d0%b2%d0%bd%d1%8b%d0%b5-%d0%b1%d0%b8%d0%bb%d0%b4%d0%b5%d1%80%d1%8b-%d0%ba%d0%be%d1%80%d1%83%d1%82%d0%b8%d0%bd-%d1%80%d0%b0%d0%b7%d0%bd%d0%b8%d1%86%d0%b0-%d0%bc%d0%b5%d0%b6","status":"publish","type":"post","link":"https:\/\/nurlandroid.com\/?p=927","title":{"rendered":"\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0431\u0438\u043b\u0434\u0435\u0440\u044b \u043a\u043e\u0440\u0443\u0442\u0438\u043d? \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 launch \u0438 async"},"content":{"rendered":"\n<p>\u0412 Kotlin Coroutines \u0435\u0441\u0442\u044c <strong>\u0442\u0440\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0431\u0438\u043b\u0434\u0435\u0440\u0430<\/strong> \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u043e\u0440\u0443\u0442\u0438\u043d:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>launch()<\/strong> &#8212; \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0443 <strong>\u0431\u0435\u0437<\/strong> \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 Job. \u041b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f UI-\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439, \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438, \u043b\u043e\u0433\u0438, \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0432 \u0411\u0414 \u0431\u0435\u0437 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430<\/li>\n\n\n\n<li><strong>async()<\/strong> &#8212; \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0443 <strong>\u0441<\/strong> \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>Deferred&lt;T><\/code> (\u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 <code>Future<\/code>). \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u0435\u043d \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 API)<\/li>\n\n\n\n<li>runBlocking() &#8212; \u0411\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043f\u043e\u0442\u043e\u043a \u0434\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u043b\u043e\u043a\u0430.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">\u041a\u043b\u044e\u0447\u0435\u0432\u0430\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 <strong>launch()<\/strong> \u0438 <strong>async()<\/strong><\/h4>\n\n\n\n<p><strong>launch()<\/strong> \u2014 \u044d\u0442\u043e fire-and-forget, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 Job, \u043e\u0448\u0438\u0431\u043a\u0438 \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u043e\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432\u0432\u0435\u0440\u0445. <strong>async()<\/strong> \u2014 \u044d\u0442\u043e \u00ab\u0431\u0443\u0434\u0443\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u00bb, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <strong>Deferred<\/strong>, \u043e\u0448\u0438\u0431\u043a\u0438 \u043e\u0442\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0438 \u0432\u044b\u0441\u0442\u0440\u0435\u043b\u0438\u0432\u0430\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 <strong>await()<\/strong>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u041e\u0448\u0438\u0431\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0447\u0430\u0441\u0442\u043e \u0434\u0435\u043b\u0430\u044e\u0442:<\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u041e\u0448\u0438\u0431\u043a\u0430<\/th><th>\u041f\u043e\u0447\u0435\u043c\u0443 \u043f\u043b\u043e\u0445\u043e?<\/th><\/tr><\/thead><tbody><tr><td><code>val data = async { ... }<\/code> \u0431\u0435\u0437 <code>await()<\/code><\/td><td>\u041a\u043e\u0440\u0443\u0442\u0438\u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f, \u043d\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f<\/td><\/tr><tr><td><code>async<\/code> \u0431\u0435\u0437 <code>try-catch<\/code> \u0432\u043e\u043a\u0440\u0443\u0433 <code>await()<\/code><\/td><td>\u0418\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 \u043f\u0440\u0438 <code>await<\/code>, \u043d\u0435 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 <code>async<\/code><\/td><\/tr><tr><td>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>runBlocking<\/code> \u0432 UI\/\u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445<\/td><td>\u0411\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u0442\u043e\u043a, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u0435\u0441\u0442\u0430\u0445 <\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412 Kotlin Coroutines \u0435\u0441\u0442\u044c \u0442\u0440\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0431\u0438\u043b\u0434\u0435\u0440\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u043e\u0440\u0443\u0442\u0438\u043d: \u041a\u043b\u044e\u0447\u0435\u0432\u0430\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 launch() \u0438 async() launch() \u2014 \u044d\u0442\u043e fire-and-forget, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 Job, \u043e\u0448\u0438\u0431\u043a\u0438 \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u043e\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432\u0432\u0435\u0440\u0445. async() \u2014 \u044d\u0442\u043e \u00ab\u0431\u0443\u0434\u0443\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u00bb, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 Deferred, \u043e\u0448\u0438\u0431\u043a\u0438 \u043e\u0442\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0438 \u0432\u044b\u0441\u0442\u0440\u0435\u043b\u0438\u0432\u0430\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 await(). \u041e\u0448\u0438\u0431\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0447\u0430\u0441\u0442\u043e \u0434\u0435\u043b\u0430\u044e\u0442: \u041e\u0448\u0438\u0431\u043a\u0430 \u041f\u043e\u0447\u0435\u043c\u0443 \u043f\u043b\u043e\u0445\u043e? val data = async { &#8230; } [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,21],"tags":[],"class_list":["post-927","post","type-post","status-publish","format-standard","hentry","category-coroutines","category-kotlin"],"_links":{"self":[{"href":"https:\/\/nurlandroid.com\/index.php?rest_route=\/wp\/v2\/posts\/927","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nurlandroid.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nurlandroid.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nurlandroid.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nurlandroid.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=927"}],"version-history":[{"count":1,"href":"https:\/\/nurlandroid.com\/index.php?rest_route=\/wp\/v2\/posts\/927\/revisions"}],"predecessor-version":[{"id":928,"href":"https:\/\/nurlandroid.com\/index.php?rest_route=\/wp\/v2\/posts\/927\/revisions\/928"}],"wp:attachment":[{"href":"https:\/\/nurlandroid.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=927"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nurlandroid.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=927"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nurlandroid.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=927"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}