{"height":"190","width":"100%","provider_url":"https://hatena.blog","provider_name":"Hatena Blog","type":"rich","author_name":"unageanu","author_url":"https://blog.hatena.ne.jp/unageanu/","title":" Thread#raise","version":"1.0","description":"Thread#raise\u3067\u3001\u4efb\u610f\u306e\u30b9\u30ec\u30c3\u30c9\u3067\u5f37\u5236\u7684\u306b\u4f8b\u5916\u3092\u767a\u751f\u3055\u305b\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002 \u4f8b\u5916\u306a\u306e\u3067\u3001\u30b9\u30ec\u30c3\u30c9\u5185\u3067\u6355\u6349(catch)\u3057\u3066\u51e6\u7406\u3092\u632f\u308a\u5225\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 ensure\u30d6\u30ed\u30c3\u30af\u3082\u3061\u3083\u3093\u3068\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002 t = Thread.fork { begin p \"start\" i = 0 while true p i+=1 sleep 0.2 end p \"end\" # \u3053\u3053\u306b\u306f\u6765\u306a\u3044 ensure p \"ensure\" end } sleep 1 t.raise RuntimeError, \"stop.\" t.value #\u30b9\u30ec\u30c3\u30c9\u5185\u3067\u767a\u751f\u3057\u305f\u4f8b\u5916\u304c\u30b9\u30ed\u30fc\u3055\u308c\u308b \u5b9f\u884c\u7d50\u679c\u3067\u3059\u3002 \"star\u2026","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Funageanu.hatenablog.com%2Fentry%2F20090630%2F1246359982\" title=\" Thread#raise - \u3046\u306a\u306e\u65e5\u8a18\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","url":"https://unageanu.hatenablog.com/entry/20090630/1246359982","image_url":null,"blog_title":"\u3046\u306a\u306e\u65e5\u8a18","published":"2009-06-30 20:06:22","blog_url":"https://unageanu.hatenablog.com/","categories":["Ruby"]}