タグ

ブックマーク / yohhoy.hatenadiary.jp (2)

  • Underscore As A Keyword - yohhoyの日記

    Java 9では1文字アンダースコア(_)はキーワード(keyword)に変更され、変数名などに利用するとコンパイルエラーになる。Java 8以前は非推奨の識別子(identifier)であり、コンパイル時の警告メッセージにとどまっていた。 class UAAK { public static void main(String[] args) { int _ = 42; } } Java 8コンパイル警告メッセージ: warning: '_' used as an identifier (use of '_' as an identifier might not be supported in releases after Java SE 8) Java 9コンパイルエラー: error: as of release 9, '_' is a keyword, and may not be

    Underscore As A Keyword - yohhoyの日記
    igrep
    igrep 2021/02/25
    Java 9からかー。
  • mutexの制約とバイナリセマフォ - yohhoyの日記

    C++11標準ライブラリのstd::mutexオブジェクトでは、ロック取得/解放を同一スレッド*1から行わなければならない。(N3337 30.2.5.2/p3) m.unlock() Requires: The current execution agent shall hold a lock on m. この制約条件のため、下記コードのmutexオブジェクト利用は未定義動作(undefined behavior)を引き起こす。 #include <thread> #include <mutex> std::mutex mtx; // mutexオブジェクト int resource; // 保護対象のリソース void proc() { // resourceを使う処理B mtx.unlock(); // (2) NG:別スレッドでロック解放...したい //... } int mai

    mutexの制約とバイナリセマフォ - yohhoyの日記
  • 1