谁负责调用线程句柄的CloseHandle()(Who's responsibility is it to call CloseHandle() for Thread handle)
我有一个
Class
,其中有一个成员属性HANDLE handle
到一个线程(我们可以认为它在这个点上被设置为NULL
)。 在某些时候,Class
一个方法使用CreateThread()
它自己的方法之一Class::threaded()
(使用另一个在类本身外部的函数,但这里并不重要CreateThread()
。 调用线程然后可以继续在Class
之外的其他功能。由于必须为从
CreateThread()
返回的HANDLE
调用CloseHandle()
,所以我想知道是否在它返回之前从Class::threaded()
调用它是一个体面的解决方案。I have a class
Class
in which there's a member propertyHANDLE handle
to a thread (We can assume it is set toNULL
at that point) . at some point , a method withinClass
dispatches one of it's own methodsClass::threaded()
(using another function that is external to the class itself, but it doesn't really matter here) withCreateThread()
. The calling thread will then may continue to other function outside ofClass
.As
CloseHandle()
must be called for theHANDLE
returned fromCreateThread()
, I was wondering if calling it fromClass::threaded()
just before it returns would be a decent solution.
原文:https://stackoverflow.com/questions/20254197
最满意答案
因为您在定义
i
和j
之前尝试创建Card
。 另外,请使用大括号。// Card card = new Card(j,i); for (int i=0; i<=3; i++) { for (int j=0; j<= 13; j++) { Card card = new Card(j,i); originalDecks.add(card); } }
Because you try to create a
Card
before you definei
andj
. Also, please use braces.// Card card = new Card(j,i); for (int i=0; i<=3; i++) { for (int j=0; j<= 13; j++) { Card card = new Card(j,i); originalDecks.add(card); } }
相关问答
更多-
简短的答案是:因为语言设计师决定不去。 基本上,似乎.NET和Java设计人员都不允许多重继承,因为他们认为添加MI在语言上增加了太多的复杂性 ,同时提供了太少的好处 。 为了更有趣和深入的阅读,有一些文章可以在网络上访问一些语言设计师。 例如,对于.NET,Chris Brumme(在CLR的MS工作)已经解释了为什么他们决定不: 实际上,不同的语言对MI的工作有着不同的期望。 例如,冲突如何解决以及重复基础是合并还是多余的。 在CLR实施MI之前,我们必须对所有语言进行调查,找出常见的概念,并决定如何用 ...
-
您不能声明和初始化第二种类型的变量,但您可以拥有相同类型的多个变量(可能具有初始化)。 这是在局部变量中缓存绑定的常用习惯用法: String s = "Hello"; for (int i = 0, L = s.length(); i < L; i++) { System.out.println(s.charAt(i)); } // prints "H", "e", "l", "l", "o" 这是映射1D-2D阵列的常用习惯用法: int[] arr1d = new int[9]; int[] ...
-
java.util.Scanner不允许对象声明[重复](java.util.Scanner Object Declaration not Allowed Here [duplicate])[2022-09-08]
您可以根据需要使用和声明尽可能多的扫描仪......(这是一种不好的做法,但对此没有技术限制......) ...... 指出我错在哪里 ...... 错误是: 扫描程序无法解析为变量错误的原因是您尝试在if else范围内声明对象但没有使用花括号{} 替换方法中的代码: if (cat.equals("Government")) { Scanner s = new Scanner(new File("ugov.dat")); } else { Scanner s = new Scanner ... -
在C中(在C99之前),你必须在块的开始处声明变量。 将代码编译为C99,或更改代码,以便在块的开头声明f 。 In C (prior to C99), you have to declare variables at the start of a block. Either compile your code as C99, or change the code so that f is declared at the start of a block.
-
因为您在定义i和j之前尝试创建Card 。 另外,请使用大括号。 // Card card = new Card(j,i); for (int i=0; i<=3; i++) { for (int j=0; j<= 13; j++) { Card card = new Card(j,i); originalDecks.add(card); } } Because you try to create a Card before you define i ...
-
实际上,gcc错误信息是非常有用的:语法实际上允许auto f()() -> int ,但是这种语法正确的声明在语义上是无效的。 它会描述一个返回返回int的函数的函数。 标准报价看到ecatmur的答案不允许。 为了理解解析,像这样工作。 f是你想要声明的。 向右解析,你会发现一个空的参数列表,所以f()是一个有效的表达式,并且该表达式的类型被声明。 再次解析右边,你会再次找到一个参数列表,所以f的返回类型是一个采用零参数的函数。 再次解析到右侧,并且您将点击结尾( ->箭头),因此解析到左侧以查找结果类 ...
-
private Result Execute
( out T returnValue, string storedProcedureName, Hashtable parameters, ExecuteType executeType ... -
Java中的奇怪数组声明(Strange array declaration in Java)[2023-07-01]
这是无效的语法。 有关声明数组的正确语法,请参阅Java语言规范。 规格 。 规范明确规定: 数组初始值设定项被写为逗号分隔的表达式列表,用大括号{和}括起来。 没有提到添加管道或嵌套支架。 This is invalid syntax. See the Java Language Specification for the correct syntax for declaring an array. Specification. The specification specifically states: ... -
请参阅此主题中的Ian答案: https : //groups.google.com/forum/#! msg / golang -nuts / qTZemuGDV6o / IyCwXPJsUFIJ 在顶层,每个声明都以关键字开头。 这简化了解析。 See the Ian's answer in this thread: https://groups.google.com/forum/#!msg/golang-nuts/qTZemuGDV6o/IyCwXPJsUFIJ At the top level, e ...
-
Java / Android不允许“this”作为Intent声明中的参数(Java/Android will not allow “this” as parameter in Intent declaration)[2022-02-01]
您在内部类 AsyncCaller因此this指的是该类。 如果外部类名为YourActivityClass以引用外部类,则可以使用例如YourActivityClass.this You are in the inner class AsyncCaller so this refers to that class. You can use e.g. YourActivityClass.this if the outer class is named YourActivityClass to referen ...