Zasadniczo mam kilka klas, które wywołują statyczną pustkę, która dostarcza argumenty: (used in an ASP website)
.Czy metody statyczne bez wątków są bezpieczne?
Z mojego zrozumienia, ponieważ pustka ma własny stos, jest bezpieczna dla wątków, ale nie jestem do końca pewna, czy to prawda, gdy są używane outs. Czy ktoś może wyjaśnić problem? Dzięki!
namespace ThreadTest
{
class Program
{
static void Main(string[] args)
{
int helloWorldint = 0;
bool helloWorldbool = false;
int helloWorldintOut = 0;
bool helloWorldboolOut = false;
setHelloWorlds(helloWorldint, helloWorldbool, out helloWorldintOut, out helloWorldboolOut);
Console.WriteLine(helloWorldintOut);
Console.WriteLine(helloWorldboolOut);
}
public static void setHelloWorlds(int helloWorldint, bool helloWorldbool, out int helloWorldintOut, out bool helloWorldboolOut)
{
helloWorldintOut = helloWorldint + 1;
helloWorldboolOut = true;
}
}
}
Gdzie wkraczają wątki? – Markus
@Markus ASP Witryna tej samej puli aplikacji – user6445891
Dlaczego nie zwracać obiektów zamiast używać outs? –