{"id":6647,"date":"2014-06-08T09:15:22","date_gmt":"2014-06-08T00:15:22","guid":{"rendered":"http:\/\/www.gesource.jp\/weblog\/?p=6647"},"modified":"2017-07-16T08:52:09","modified_gmt":"2017-07-15T23:52:09","slug":"tthreadlist%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9","status":"publish","type":"post","link":"https:\/\/www.gesource.jp\/weblog\/?p=6647","title":{"rendered":"TThreadList\u306e\u4f7f\u3044\u65b9"},"content":{"rendered":"<h3>TThreadList\u3068\u306f<\/h3>\n<p>TThreadList\u306f\u3001TList\u306e\u30b9\u30ec\u30c3\u30c9\u30bb\u30fc\u30d5\u306a\u30e9\u30c3\u30d1\u30fc\u3067\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yuml.me\/40f492d4\" alt=\"\" \/><\/p>\n<h3>\u9805\u76ee\u306e\u8ffd\u52a0\u3068\u524a\u9664<\/h3>\n<p>\u9805\u76ee\u306e\u8ffd\u52a0\u3084\u524a\u9664\u3092\u884c\u3046\u30e1\u30bd\u30c3\u30c9\u306f\u30b9\u30ec\u30c3\u30c9\u30bb\u30fc\u30d5\u3067\u3059\u3002<\/p>\n<pre><code>\/\/\u9805\u76ee\u3092\u30ea\u30b9\u30c8\u306e\u6700\u5f8c\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002\nprocedure Add(const Item: T);\n\/\/\u30ea\u30b9\u30c8\u306e\u3059\u3079\u3066\u306e\u9805\u76ee\u3092\u524a\u9664\u3057\u307e\u3059\u3002\nprocedure Clear;\n\/\/\u9805\u76ee\u306e\u6700\u521d\u306e\u51fa\u73fe\u7b87\u6240\u3092\u524a\u9664\u3057\u307e\u3059\nprocedure Remove(const Item: T);\n\/\/\u6307\u5b9a\u3055\u308c\u305f\u65b9\u5411\u306b\u30eb\u30fc\u30d7\u51e6\u7406\u3057\u3066\u3001\u6700\u521d\u306b\u898b\u3064\u304b\u3063\u305f\u9805\u76ee\u3092\u524a\u9664\u3057\u307e\u3059\u3002\nprocedure RemoveItem(const Item: T; Direction: TDirection);\n<\/code><\/pre>\n<h4>\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9<\/h4>\n<pre><code>uses System.Generics.Collections;\n\nThreadList := TThreadList&lt;string&gt;.Create;\n\n\/\/\u8ffd\u52a0\u3084\u524a\u9664\u306f\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3059\u3060\u3051\nThreadList.Add('Delphi');\nThreadList.Add('C++Builder');\nThreadList.Add('RAD Studio');\nThreadList.Add('HTML5 Builder');\nThreadList.Remove('HTML5 Builder');\n<\/code><\/pre>\n<h3>\u30ea\u30b9\u30c8\u306e\u9805\u76ee\u3092\u64cd\u4f5c\u3059\u308b<\/h3>\n<p>\u30ea\u30b9\u30c8\u306e\u9805\u76ee\u3092\u53d6\u5f97\u3057\u305f\u308a\u5909\u66f4\u3059\u308b\u3068\u304d\u306f\u3001LockList\u30e1\u30bd\u30c3\u30c9\u3067\u30ea\u30b9\u30c8\u3092\u30ed\u30c3\u30af\u3057\u307e\u3059\u3002<br \/>\n\u4f5c\u696d\u304c\u7d42\u308f\u3063\u305f\u3089\u3001UnlockList\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3057\u3066\u3001\u30ed\u30c3\u30af\u3092\u89e3\u9664\u3057\u307e\u3059\u3002<\/p>\n<h4>\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9<\/h4>\n<pre><code>procedure TForm1.Print(ThreadList: TThreadList&lt;string&gt;);\nvar\n  List: TList&lt;string&gt;;\n  S: string;\nbegin\n  try\n    \/\/ \u30ea\u30b9\u30c8\u306e\u8981\u7d20\u306b\u64cd\u4f5c\u3059\u308b\u3068\u304d\u306f\u30ea\u30b9\u30c8\u3092\u30ed\u30c3\u30af\u3059\u308b\n    List := ThreadList.LockList;\n    \/\/ \u30ea\u30b9\u30c8\u3092\u30ed\u30c3\u30af\u3057\u3066\u304b\u3089\u8981\u7d20\u3092\u64cd\u4f5c\u3059\u308b\n    for S in List do\n    begin\n      Memo1.Lines.Add(S);\n    end;\n  finally\n    \/\/ \u51e6\u7406\u304c\u7d42\u308f\u3063\u305f\u3089\u30ed\u30c3\u30af\u3092\u89e3\u9664\u3059\u308b\n    ThreadList.UnlockList;\n  end;\n  ThreadList.Free;\nend;\n<\/code><\/pre>\n<h3>\u30ea\u30b9\u30c8\u306e\u9805\u76ee\u306e\u5909\u66f4\u3092\u77e5\u308b\u306b\u306f<\/h3>\n<p>\u30ea\u30b9\u30c8\u306e\u9805\u76ee\u306e\u5909\u66f4\u3092\u77e5\u308b\u306b\u306f\u3001TThreadList\u304c\u6240\u6709\u3059\u308bTList\u306eOnNotify\u30a4\u30d9\u30f3\u30c8\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<h4>\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9<\/h4>\n<p>\u30ea\u30b9\u30c8\u306e\u9805\u76ee\u304c\u5909\u66f4\u3055\u308c\u305f\u3068\u304d\u306b\u547c\u3073\u51fa\u3055\u308c\u308b\u30a4\u30d9\u30f3\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre><code>type\n  TForm1 = class(TForm)\n  \u2026\n  private\n    { private \u5ba3\u8a00 }\n    \/\/\/ &lt;summary&gt;\n    \/\/\/   \u30ea\u30b9\u30c8\u306e\u9805\u76ee\u304c\u5909\u66f4\u3055\u308c\u305f\u3068\u304d\u306b\u547c\u3073\u51fa\u3055\u308c\u308b\u30a4\u30d9\u30f3\u30c8\n    \/\/\/ &lt;\/summary&gt;\n    procedure OnListNofity(Sender: TObject; const Item: string;\n      Action: System.Generics.Collections.TCollectionNotification);\n  \u2026\n  end;\n\nprocedure TForm1.OnListNofity(Sender: TObject; const Item: string;\n  Action: System.Generics.Collections.TCollectionNotification);\nbegin\n  case Action of\n    cnAdded: \/\/ \u30a8\u30f3\u30c8\u30ea\u304c\u30ea\u30b9\u30c8\u306b\u8ffd\u52a0\u3055\u308c\u305f\n      Memo1.Lines.Add('\u8ffd\u52a0\uff1a' + Item);\n    cnRemoved: \/\/ \u30a8\u30f3\u30c8\u30ea\u304c\u30ea\u30b9\u30c8\u304b\u3089\u524a\u9664\u3055\u308c\u305f\n      Memo1.Lines.Add('\u524a\u9664\uff1a' + Item);\n    cnExtracted: \/\/ \u30a8\u30f3\u30c8\u30ea\u304c\u30ea\u30b9\u30c8\u304b\u3089\u62bd\u51fa\u3055\u308c\u305f\n      Memo1.Lines.Add('\u62bd\u51fa\uff1a' + Item);\n  end;\nend;\n<\/code><\/pre>\n<p>\u30a4\u30d9\u30f3\u30c8\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre><code>ThreadList := TThreadList&lt;string&gt;.Create;\nList := ThreadList.LockList;\nList.OnNotify := Self.OnListNofity;\nThreadList.UnlockList;\n<\/code><\/pre>\n<h3>\u30b5\u30f3\u30d7\u30eb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3<\/h3>\n<p>\u6b21\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306f\u30ea\u30b9\u30c8\u306e\u9805\u76ee\u304c\u5909\u66f4\u3055\u308c\u305f\u3068\u304d\u3068\u3001\u30ea\u30b9\u30c8\u306e\u9805\u76ee\u3092\u30e1\u30e2\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u59d4\u306b\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<p>Delphi XE3\/XE5\/XE6\u3067\u78ba\u8a8d\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>FireMonkey\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u2192HD FireMonkey\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\u30d5\u30a9\u30fc\u30e0\u306b\u30dc\u30bf\u30f3\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3068\u30e1\u30e2\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u914d\u7f6e\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.gesource.jp\/weblog\/wp-content\/uploads\/2014\/06\/01.gif\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.gesource.jp\/weblog\/wp-content\/uploads\/2014\/06\/01.gif?resize=255%2C279\" alt=\"01\" width=\"255\" height=\"279\" class=\"alignnone size-full wp-image-6654\" \/><\/a><\/p>\n<p>uses\u306b\u300cSystem.Generics.Collections\u300d\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p>\u30ea\u30b9\u30c8\u306e\u9805\u76ee\u304c\u5909\u66f4\u3055\u308c\u305f\u3068\u304d\u306b\u547c\u3073\u51fa\u3055\u308c\u308bprivate\u30e1\u30bd\u30c3\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre><code>type\n  TForm1 = class(TForm)\n    Button1: TButton;\n    Memo1: TMemo;\n  private\n    { private \u5ba3\u8a00 }\n    \/\/\/ &lt;summary&gt;\n    \/\/\/ \u30ea\u30b9\u30c8\u306e\u9805\u76ee\u304c\u5909\u66f4\u3055\u308c\u305f\u3068\u304d\u306b\u547c\u3073\u51fa\u3055\u308c\u308b\u30a4\u30d9\u30f3\u30c8\n    \/\/\/ &lt;\/summary&gt;\n    procedure OnListNofity(Sender: TObject; const Item: string;\n      Action: System.Generics.Collections.TCollectionNotification);\n  public\n    { public \u5ba3\u8a00 }\n  end;\n\nprocedure TForm1.OnListNofity(Sender: TObject; const Item: string;\n  Action: System.Generics.Collections.TCollectionNotification);\nbegin\n  case Action of\n    cnAdded: \/\/ \u9805\u76ee\u304c\u30ea\u30b9\u30c8\u306b\u8ffd\u52a0\u3055\u308c\u305f\n      Memo1.Lines.Add('\u8ffd\u52a0\uff1a' + Item);\n    cnRemoved: \/\/ \u9805\u76ee\u304c\u30ea\u30b9\u30c8\u304b\u3089\u524a\u9664\u3055\u308c\u305f\n      Memo1.Lines.Add('\u524a\u9664\uff1a' + Item);\n    cnExtracted: \/\/ \u9805\u76ee\u304c\u30ea\u30b9\u30c8\u304b\u3089\u62bd\u51fa\u3055\u308c\u305f\n      Memo1.Lines.Add('\u62bd\u51fa\uff1a' + Item);\n  end;\nend;\n<\/code><\/pre>\n<p>\u30dc\u30bf\u30f3\u306eOnClick\u30a4\u30d9\u30f3\u30c8\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre><code>procedure TForm1.Button1Click(Sender: TObject);\nvar\n  ThreadList: TThreadList&lt;string&gt;;\n  List: TList&lt;string&gt;;\n  S: string;\nbegin\n  ThreadList := TThreadList&lt;string&gt;.Create;\n  List := ThreadList.LockList;\n  \/\/ \u9805\u76ee\u304c\u5909\u66f4\u3055\u308c\u305f\u3068\u304d\u306b\u547c\u3073\u51fa\u3055\u308c\u308b\u30a4\u30d9\u30f3\u30c8\u3092\u8a2d\u5b9a\u3059\u308b\n  List.OnNotify := Self.OnListNofity;\n  ThreadList.UnlockList;\n\n  ThreadList.Add('Delphi'); \/\/ \u8ffd\u52a0\n  ThreadList.Add('C++Builder'); \/\/ \u8ffd\u52a0\n  ThreadList.Add('RAD Studio'); \/\/ \u8ffd\u52a0\n  ThreadList.Add('HTML5 Builder'); \/\/ \u8ffd\u52a0\n  ThreadList.Remove('HTML5 Builder'); \/\/ \u524a\u9664\n\n  List := ThreadList.LockList;\n  List.Items[2] := 'RAD Studio XE6'; \/\/ \u7f6e\u63db\n\n  \/\/ \u9805\u76ee\u306e\u8868\u793a\n  for S in List do\n  begin\n    Memo1.Lines.Add('\u8981\u7d20\uff1a' + S);\n  end;\n  ThreadList.UnlockList;\n\n  \/\/ \u30af\u30ea\u30a2\n  ThreadList.Clear;\n\n  ThreadList.Free;\nend;\n<\/code><\/pre>\n<p>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.gesource.jp\/weblog\/wp-content\/uploads\/2014\/06\/02.gif\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.gesource.jp\/weblog\/wp-content\/uploads\/2014\/06\/02.gif?resize=256%2C280\" alt=\"02\" width=\"256\" height=\"280\" class=\"alignnone size-full wp-image-6655\" \/><\/a><\/p>\n<p>\u30ea\u30b9\u30c8\u306e\u9805\u76ee\u306e\u72b6\u614b\u304c\u8868\u793a\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>TThreadList\u3068\u306f TThreadList\u306f\u3001TList\u306e\u30b9\u30ec\u30c3\u30c9\u30bb\u30fc\u30d5\u306a\u30e9\u30c3\u30d1\u30fc\u3067\u3059\u3002 \u9805\u76ee\u306e\u8ffd\u52a0\u3068\u524a\u9664 \u9805\u76ee\u306e\u8ffd\u52a0\u3084\u524a\u9664\u3092\u884c\u3046\u30e1\u30bd\u30c3\u30c9\u306f\u30b9\u30ec\u30c3\u30c9\u30bb\u30fc\u30d5\u3067\u3059\u3002 \/\/\u9805\u76ee\u3092\u30ea\u30b9\u30c8\u306e\u6700\u5f8c\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002 proced &#8230;<\/p>\n<p><a href=\"https:\/\/www.gesource.jp\/weblog\/?p=6647\" class=\"more-link\">Continue reading &lsquo;TThreadList\u306e\u4f7f\u3044\u65b9&rsquo; &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[48],"tags":[156,132],"class_list":["post-6647","post","type-post","status-publish","format-standard","hentry","category-delphi","tag-delphi","tag-xe6"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/posts\/6647","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6647"}],"version-history":[{"count":0,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/posts\/6647\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}