use threads; するときに注意すべきこと

use threads; で1日嵌った。
環境は Active Perl - v5.10.1 built for MSWin32-x86-multi-thread

threadsを使う時、標準出力のエンコードをbinmodeで指定しておくとインタプリタが落ちる。なので、

my $cp932 = find_encoding('cp932');
print $cp932->encode("番組が終了しました");

ように文字コードを指定しておく。

次のように書くとクラッシュする

binmode STDOUT, ":encoding(cp932)";

エンコードに関する参考
http://blog.livedoor.jp/dankogai/archives/51031595.html