{"id":1730,"date":"2013-07-09T17:25:49","date_gmt":"2013-07-09T22:25:49","guid":{"rendered":"http:\/\/alejandroayala.solmedia.ec\/?p=1730"},"modified":"2014-08-11T15:31:08","modified_gmt":"2014-08-11T20:31:08","slug":"resumen-ocpscjp-capitulo-9-hilos-threads","status":"publish","type":"post","link":"https:\/\/alejandroayala.solmedia.ec\/?p=1730","title":{"rendered":"Resumen OCP(SCJP): Cap\u00edtulo 9. Hilos (Threads)"},"content":{"rendered":"<h3>DEFINICI\u00d3N, INSTANCIACI\u00d3N E INICIACI\u00d3N DE THREADS (HILOS) (OBJETIVO 4.1)<\/h3>\n<ul>\n<li>El m\u00e9todo <em>start()<\/em> m\u00e1s de una sola vez lanza <em>IllegalThreadStateException<\/em> (la cual extiende de <em>RuntimeException<\/em>).<\/li>\n<\/ul>\n<h3>TRANSICIONES ENTRE ESTADOS DE HILOS (OBJETIVO 4.2)<\/h3>\n<ul>\n<li>Existen cinco estados: \u201cnuevo\u201d, \u201cejecutable\u201d, \u201cen ejecuci\u00f3n\u201d, \u201cbloqueado\/esperando\/ dormido\u201d, y \u201cmuerto\u201d (<em>new<\/em>, <em>runnable<\/em>, <em>running<\/em>, <em>blocked<\/em>\/<em>waiting<\/em>\/<em>sleeping<\/em>, <em>dead<\/em>).<\/li>\n<\/ul>\n<div id=\"attachment_1731\" style=\"width: 366px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/solmedia.ec\/blog\/wp-content\/uploads\/2014\/07\/hilos.png\"><img aria-describedby=\"caption-attachment-1731\" loading=\"lazy\" class=\"size-full wp-image-1731\" src=\"http:\/\/solmedia.ec\/blog\/wp-content\/uploads\/2014\/07\/hilos.png\" alt=\"Estados de los hilos\" width=\"356\" height=\"165\" srcset=\"http:\/\/solmedia.ec\/blog\/wp-content\/uploads\/2014\/07\/hilos.png 356w, http:\/\/solmedia.ec\/blog\/wp-content\/uploads\/2014\/07\/hilos-300x139.png 300w\" sizes=\"(max-width: 356px) 100vw, 356px\" \/><\/a><p id=\"caption-attachment-1731\" class=\"wp-caption-text\">Estados de los hilos<\/p><\/div>\n<h3>SLEEP, YIELD Y JOIN (OBJETIVO 4.2)<\/h3>\n<ul>\n<li>El m\u00e9todo <em>setPriority()<\/em> se utiliza, solo sobre instancias de Thread, para dar una prioridad a los hilos entre los valores 1(baja) y 10(alta)<\/li>\n<\/ul>\n<h3>PROBLEMAS DE ACCESO CONCURRENTE Y SINCRONIZACI\u00d3N DE HILOS (OBJETIVO 4.3)<\/h3>\n<ul>\n<li>Los m\u00e9todos est\u00e1ticos pueden estar sincronizados, utilizando como cerradura la instancia <em>java.lang.Class<\/em> que representa la clase.<\/li>\n<\/ul>\n<h3>COMUNICACI\u00d3N CON OBJETOS A TRAV\u00c9S DE WAIT() Y NOTIFY() (OBJETIVO 4.4)<\/h3>\n<ul>\n<li>Los m\u00e9todos <em>wait(), notify() y notifyAll()<\/em> deben ser invocados desde un contexto sincronizado.<\/li>\n<li>Un punto a tomar en cuenta es que para poder llamar al m\u00e9todo <em>wait()<\/em>, se tuvo que sincronizar el bloque de c\u00f3digo y obtener el bloqueo de <em>b,<\/em> de lo contrario se obtiene una excepci\u00f3n de tipo <em>java.lang.IllegalMonitorStateException<\/em><\/li>\n<\/ul>\n<h4>EOF<\/h4>\n\n<div class=\"twitter-share\"><a href=\"https:\/\/twitter.com\/intent\/tweet?via=a1ejo_ayala\" class=\"twitter-share-button\" data-size=\"large\">Twittear<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>DEFINICI\u00d3N, INSTANCIACI\u00d3N E INICIACI\u00d3N DE THREADS (HILOS) (OBJETIVO 4.1) El m\u00e9todo start() m\u00e1s de una sola vez lanza IllegalThreadStateException (la cual extiende de RuntimeException). TRANSICIONES ENTRE ESTADOS DE HILOS (OBJETIVO 4.2) Existen cinco estados: \u201cnuevo\u201d, \u201cejecutable\u201d, \u201cen ejecuci\u00f3n\u201d, \u201cbloqueado\/esperando\/ dormido\u201d, y \u201cmuerto\u201d (new, runnable, running, blocked\/waiting\/sleeping, dead). SLEEP, YIELD Y JOIN (OBJETIVO 4.2) El m\u00e9todo\u2026 <span class=\"read-more\"><a href=\"https:\/\/alejandroayala.solmedia.ec\/?p=1730\">Leer m\u00e1s &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":690,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false},"categories":[4],"tags":[447,506,446,326],"_links":{"self":[{"href":"https:\/\/alejandroayala.solmedia.ec\/index.php?rest_route=\/wp\/v2\/posts\/1730"}],"collection":[{"href":"https:\/\/alejandroayala.solmedia.ec\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alejandroayala.solmedia.ec\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alejandroayala.solmedia.ec\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alejandroayala.solmedia.ec\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1730"}],"version-history":[{"count":1,"href":"https:\/\/alejandroayala.solmedia.ec\/index.php?rest_route=\/wp\/v2\/posts\/1730\/revisions"}],"predecessor-version":[{"id":1732,"href":"https:\/\/alejandroayala.solmedia.ec\/index.php?rest_route=\/wp\/v2\/posts\/1730\/revisions\/1732"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/alejandroayala.solmedia.ec\/index.php?rest_route=\/wp\/v2\/media\/690"}],"wp:attachment":[{"href":"https:\/\/alejandroayala.solmedia.ec\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1730"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alejandroayala.solmedia.ec\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1730"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alejandroayala.solmedia.ec\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1730"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}