You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
本日のJava読書会「JUnit実践入門」において、次のサンプルコードからスレッドリークの有無が話題になりました。 public void invoke() { Executors.newSingleThreadExecutor().execute(task); } Executorはスレッドを内部に抱えるので、invoke()が何回も呼ばれ、shutdown()をしてあげてないこのコードではスレッドリークが生じるのでは?ということでした。 ここで生成されるExecutorインスタンスはメソッドスコープなので、すぐにGCされる対象となるのでは? という意見もありましたが、shutdownしないとスレッドが保持されたままでGCされないのでは、ということのようです。 で、jdk 7のライブラリのソースコード(jdkインストールディレクトリのsrc.zip)を調べてみました。 まず、Execut
Java EE環境では基本的にスレッドの生成は許されていません。この制限はEJB仕様書に記述されており、ブループリントなど他のドキュメントにも記載されています。これらの制限はかなり古い時代に考えうる最大の制限を記述したものであり、「ファイルにアクセスしてはならない」など今となってはあまり現実的ではない記述も多くなっています。しかしながら、「スレッドを生成してはならない」というのは依然多くのコンテナに適用される現在も有効な制限であり、実際にスレッドの生成などを行うと誤動作するケースがあります。今回は、なぜこのスレッドの制限があるのか、現実的にどうすれば良いのか解説します。 コンテナは様々なものをスレッドに結びつけて管理しています。様々なものというのは例えばセキュリティ、トランザクション、データソースなどのコンテナリソースです。コードのほうがイメージしやすいでしょうから、以下に擬似コードを挙げ
JavaWorld's most popular long-running series, featuring new and classic Java programming tips from your peers in the Java developer community. Java Tip: When to use ForkJoinPool vs ExecutorService Know your options for multithreaded programming on the Java platform The Fork/Join library introduced in Java 7 extends the existing Java concurrency package with support for hardware parallelism, a key
スレッドセーフにするために考えること 〜基礎編〜 - じゅんいち☆かとうの技術日誌 基礎編では、スレッドセーフについての基本的な考え方を書きました。 スレッドセーフにするには、アトミック性を保証することが必要でした。この応用編では、その点を注意しながら、実際にドメイン層の振る舞いを持つドメインモデルでどのようなことを気をつければスレッドセーフになるか考えてみたいと思います。考えながら、書いてるのでちょっとおかしいところがあるかも。ご容赦をw モデルオブジェクトを複数のスレッドで共有して操作してみる とりあえず、典型的なサンプルとして従業員と部署。。もうやだ〜このサンプル〜。とか言わないのw 以下の従業員は名前と役職、所属部署(複数可)を保持します。スレッドとか気にせずとりあえず適当にモデリング。toStringはデバッグ用にcommons-langのToStringBuilderを使います
A little-known but very useful feature slipped into JUnit 4 and recent versions of the Maven Surefire Plugin: support for parallel testing. This feature has been around for a while in TestNG, but has been missing in JUnit. And now, if you are a JUnit user, you too can run your tests in parallel! Running your tests in parallel is a powerful way to speed up your tests. Good automated tests should be
What is Kilim? Kilim is a message-passing framework for Java that provides ultra-lightweight threads and facilities for fast, safe, zero-copy messaging between these threads. It consists of a bytecode postprocessor (a "weaver"), a run time library with buffered mailboxes (multi-producer, single consumer queues) and a user-level scheduler and a type system that puts certain constraints on pointer a
Posted by jhook on December 22, 2008 at 11:34 PM | Comments (2) After spending way too much time on ways to speed up web applications, you'll find that your greatest mileage comes in database optimizations, networking, and reducing the bytes downloaded (an example). Time spent optimizing Java code is seemingly insignificant between waiting on the request, waiting on the database, waiting on the se
はてなグループの終了日を2020年1月31日(金)に決定しました 以下のエントリの通り、今年末を目処にはてなグループを終了予定である旨をお知らせしておりました。 2019年末を目処に、はてなグループの提供を終了する予定です - はてなグループ日記 このたび、正式に終了日を決定いたしましたので、以下の通りご確認ください。 終了日: 2020年1月31日(金) エクスポート希望申請期限:2020年1月31日(金) 終了日以降は、はてなグループの閲覧および投稿は行えません。日記のエクスポートが必要な方は以下の記事にしたがって手続きをしてください。 はてなグループに投稿された日記データのエクスポートについて - はてなグループ日記 ご利用のみなさまにはご迷惑をおかけいたしますが、どうぞよろしくお願いいたします。 2020-06-25 追記 はてなグループ日記のエクスポートデータは2020年2月28
A small library that lets you run JUnit tests in parallel. How it works This small library implements the org.kohsuke.junit.ParallelTestSuite class, which extends the junit.framework.TestSuite class. The ParallelTestSuite class enhances the base TestSuite class by running tests in parallel. Test objects registered to a ParallelTestSuite object run in parallel, allowing efficient test execution. Be
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く