以前、このような記事を書きました。 Concurrency Utilitiesを使った並列処理・マルチスレッドのおさらい (2013-12-26) 前回の内容は、Concurrency UtilitiesだけでなくJavaのマルチスレッドの話も一部含んでいましたが、今回は、Concurrency Utilitiesだけにフォーカスして、全体が分かるように整理してまとめ直しました。 目次 概要 準備 タスク・フレームワーク (Executor) 同期キュー シンクロナイザー 並行処理コレクション 時間単位 アトミック値型とアトミック操作 ロック・フレームワーク 概要 今回は、Concurrency UtilitiesのAPIをいくつかのグループに分類し、それぞれのグループの主要な機能を「広く浅く」紹介する、という形式でまとめています。 パッケージ単位で分け、それからjava.util.con
この記事は、個人的なおさらいのための、Java Concurrency Utilitiesの一部を使ったサンプルとメモです。 目新しいものは特にありません。 記事内のサンプルとAPIドキュメント参照はJava7(Java SE 7)を基準にしていますが、Java Concurrency Utilities自体は一部を除いてJava5(Java SE 5.0)から使えるようになっています。 あと、いつものことですが、画像がありません。 追記(2014-01-05): この機能の呼称は (Java) Concurrency Utilities が公式で、この記事内の"Utility"というのは正確ではない+混在していますのでご注意ください。ごめんなさい。 追記(2014-08-15): この記事は、キーワード"Java Concurrency Utilities"でGoogle検索した時に2番
ここ数日の佐藤先生のエントリが熱い! Erlang、Scala、Go、Javaなどの現代の言語(Erlangは古いか)における並行処理の扱い方について、それぞれの歴史的背景や意義、得手不得手などがわかりやすく紹介されてます。80年代から並行処理やオブジェクト指向を研究されてきた佐藤先生ならではの視点ですね。ちょっと長くなりますが特に私が興味深かった部分を引用します(強調は私): 佐藤一郎: Web日記 (2010年) 最近、興味深いのはオブジェクト指向言語のScalaやErlangが話題を集めていることでしょうか。どちらもActor Modelをベースにしているそうですが、オブジェクト指向言語の歴史でいうと、Actor Modelなどの並行処理用オブジェクト指向言語の研究が盛んになったのは1985年からの6,7年ぐらいだと思います(Actor Model自身はもっと古いですが)。そして19
The document discusses various aspects of concurrency in Java such as synchronized blocks, volatile variables, and reordering issues. It provides examples of how to properly synchronize access to shared mutable data using locks and compares the behavior of synchronized and volatile. The final sections cover atomicity in Java and how the volatile keyword prevents instruction reordering problems but
Javaの機能を拡張した新言語Xtendの紹介です。Eclipseで簡単に使えます。NSEG第31回勉強会(2012年9月29日)の発表資料。
Concurrent counter are part of almost every system, it is used to collect data, thread synchronization etc. Java has good support of heap based counter. There could be use case when you need counter that can be shared between processor. How to build inter process countersDatabaseThis is first option that comes to mind, database sequence is counter that can be used by multiple process. All concurre
ConcurrentHashMapを使うときの注意点 タイトルの通りです。 ConcurrentHashMapは同期を取りつつ、パフォーマンスも優れたとても優秀なやつで、最近Webアプリケーションで、キャッシュみたいなものを作るときに使いました。 とはいえ同期を取るとはいっても以下のようなキーの存在を確認して、putするような複合アクションの呼び出し(いわゆるcheck-then-act)では同期されません。(別にこれは、従来のHahMapとかCollections.syncronizedMapとかでも同じです) // atomicではない操作。 if(!map.containsKey(key)) { map.put(key, value); } 以下が実証コードで、実行すると高い確率で複数スレッドで同一キーへのputを行います。 (今回のケースだとあまり問題にならないですが、valueを
Last week I attended a review session of the new JSR166 StampedLock run by Heinz Kabutz at the excellent JCrete unconference. StampedLock is an attempt to address the contention issues that arise in a system when multiple readers concurrently access shared state. StampedLock is designed to perform better than ReentrantReadWriteLock by taking an optimistic read approach. While attending the session
CPUのクロックアップに限界が訪れ、マルチコア化することで処理性能向上を目指す時代になりました。これからのプログラマには、マルチコアで処理性能が向上するプログラム=マルチスレッドで並列処理が可能なプログラムを書く能力が必要になります。今回は「関数型」でプログラムを書くことによって、いとも簡単に並列化ができることを実例を元に解説します。 関数型プログラミングと並列処理 「関数型でプログラムを書くことで簡単に並列化できる」と書きましたが、そもそもここで言う「関数」とは何なのでしょうか? 関数型プログラミングの特徴 関数型プログラミングの「関数」を理解するためには、数学における「関数」を想像するとわかりやすいでしょう。 例えば三角関数を用いた y=cos(x) という式を考えてみます。この式に入力値 x=0 を与えた場合、いつでも必ず結果は y=1 になります。x= π/3 の場合は y =
The document discusses various concurrency models including shared state concurrency, message passing concurrency using actors, and software transactional memory. Shared state concurrency uses locking to synchronize access to shared resources but is prone to issues like race conditions and deadlocks. Message passing concurrency avoids these issues by isolating actors and having them communicate as
Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concurrency | Trisha Gee & Mike Barker 2011-11-02 | 05:45 PM - 06:35 PM | Victoria The Disruptor is new open-source concurrency framework, designed as a high performance mechanism for inter-thread messaging. It was developed at LMAX as part of our efforts to build the world's fastest financial exchange. Using the Disruptor as
If you ever wrote production multi-threaded server in Java you know how it is difficult to implement load balancing between worker threads. You need to fight many issues to have good load balancer: You need to limit somehow the number of worker threads, because with unlimited thread pool you can have memory exhausted. You need to implement sophisticated procedure for clean worker shutdown. If you
IF YOU ARE LOOKING for the drop-in replacement for java.util.Hashtable, it's in the lib directory, lib/java_util_hashtable.jar. It needs to be in your bootclasspath. Example: java -Xbootclasspath/p:lib/java_util_hashtable.jar my_java_app_goes_here --- A collection of Concurrent and Highly Scalable Utilities. These are intended as direct replacements for the java.util.* or java.util.concurrent.* co
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く