{"id":2233,"date":"2018-10-05T13:14:40","date_gmt":"2018-10-05T17:14:40","guid":{"rendered":"http:\/\/ninecrows.com\/career\/?p=2233"},"modified":"2018-10-05T13:55:46","modified_gmt":"2018-10-05T17:55:46","slug":"java-tasks-dont-do-lambdas","status":"publish","type":"post","link":"https:\/\/ninecrows.com\/career\/2018\/10\/05\/java-tasks-dont-do-lambdas\/","title":{"rendered":"Java Tasks don&#8217;t do Lambdas"},"content":{"rendered":"\n<p>I was spinning a thread recently and it was pointed out to me that the environment I was working in at the time used <a href=\"https:\/\/docs.oracle.com\/javafx\/2\/api\/javafx\/concurrent\/Task.html\">Task<\/a>\u00a0(JavaFX code) for such things. My thread was being created with a Lambda expression as the action to be performed. It surprised me when I could not directly translate that to a <a href=\"https:\/\/docs.oracle.com\/javafx\/2\/api\/javafx\/concurrent\/Task.html\">Task<\/a>.<\/p>\n\n\n\n<p>After a bit of research I found <a href=\"http:\/\/mail.openjdk.java.net\/pipermail\/lambda-dev\/2013-March\/008441.html\">this post<\/a> discussing why that is the case (as a side-effect of the fact that <a href=\"https:\/\/docs.oracle.com\/javafx\/2\/api\/javafx\/concurrent\/Task.html\">Task<\/a> is an abstract class). As with so many things in Java where the choice is to accept less expressive and longer winded approaches to limit language level complexity, I&#8217;m not sure I agree with the choice, but it is what it is at this point.<\/p>\n\n\n\n<p>Adding in the anonymous local class framing isn&#8217;t a big deal and that&#8217;s clearly the way to go for this item.\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was spinning a thread recently and it was pointed out to me that the environment I was working in at the time used Task\u00a0(JavaFX code) for such things. My thread was being created with a Lambda expression as the action to be performed. It surprised me when I could not directly translate that to &hellip; <a href=\"https:\/\/ninecrows.com\/career\/2018\/10\/05\/java-tasks-dont-do-lambdas\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Java Tasks don&#8217;t do Lambdas<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[69,7],"tags":[],"class_list":["post-2233","post","type-post","status-publish","format-standard","hentry","category-java","category-topics"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7F2Qc-A1","jetpack-related-posts":[],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/ninecrows.com\/career\/wp-json\/wp\/v2\/posts\/2233"}],"collection":[{"href":"https:\/\/ninecrows.com\/career\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ninecrows.com\/career\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ninecrows.com\/career\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ninecrows.com\/career\/wp-json\/wp\/v2\/comments?post=2233"}],"version-history":[{"count":2,"href":"https:\/\/ninecrows.com\/career\/wp-json\/wp\/v2\/posts\/2233\/revisions"}],"predecessor-version":[{"id":2235,"href":"https:\/\/ninecrows.com\/career\/wp-json\/wp\/v2\/posts\/2233\/revisions\/2235"}],"wp:attachment":[{"href":"https:\/\/ninecrows.com\/career\/wp-json\/wp\/v2\/media?parent=2233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ninecrows.com\/career\/wp-json\/wp\/v2\/categories?post=2233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ninecrows.com\/career\/wp-json\/wp\/v2\/tags?post=2233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}