Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- namespace TestDaLuong
- {
- class Program
- {
- static void Main(string[] args)
- {
- // Tạo mảng 10 thread
- Thread[] arrTh = new Thread[10];
- for (int i = 0; i < arrTh.Length; i++)
- {
- // Bắt đầu các thread với việc gán tham số
- ParameterizedThreadStart st = new ParameterizedThreadStart(Batdau);
- arrTh[i] = new Thread(st);
- arrTh[i].Start(i);
- }
- Console.ReadLine();
- }
- static void Batdau(object info)
- {
- // Lấy giá trị từ tham số sau đó convert sang int
- int value = (int)info + 10;
- Console.WriteLine(value);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment