我对多线程完全不熟悉。我正在尝试进行简单的测试 我有一个从1到100的数字列表。我想要多线程的函数只是一个函数,将数字乘以5然后是console.writeline结果
课程计划 { public static List data = new List(); public static void Main(string [] args) { new Program()。run(); foreach(数据中的int d) { Console.WriteLine(d); }
if (($_SESSION['user_id'] === $row['post_by']) || $_SESSION['user_level'] === 2 ) {
$delsql2= 'DELETE FROM posts WHERE post_id='.$id;
$stmt2= $link->query($delsql2);
header ('Location:index.php');
}
else {
var_dump($_SESSION);
echo 'You can only delete your own posts.';
}
答案 0 :(得分:1)
这就是你问的问题吗?
using System;
using System.Collections.Generic;
using System.Threading;
class Program
{
static void Main(string[] args)
{
List<int> list = new List<int>();
for (int i = 0; i <= 100; i++) { list.Add(i); }
foreach (int value in list)
{
Thread thread = new Thread(() => PrintNumberTimesFive(value));
thread.Start();
}
Console.ReadLine();
}
static void PrintNumberTimesFive(int number)
{
Console.WriteLine(number * 5);
}
}