Using system;using system.collections.generic;using system.linq;using system.web;using System.Web.UI;using System.threading;using System.web.ui.webcontrols;public partial class muti_thread:system.web.ui.page{protected void Page_Load (object sender, EventArgs e) {Thread Thread1 = new Thread (new ThreadStart (calcsum)); Thread Thread2 = new Thread (new ThreadStart (CALCGAP)); Thread1.start (); Thread2.start (); Thread1.join (); Thread2.join (); }//Sum method protected void Calcsum () {Long sum = 0; for (long i = 0; i < i++) {sum + = i; Response.Write (String. Format ("thread1-->i={0}:sum={1}<br/>", I, sum)); Response.Flush (); System.Threading.Thread.Sleep (5000); }}//differential method protected void Calcgap () {long gap = 0; for (long i = +; I >= 0; i--) {gap = i-1; Response.Write (String. Format ("thread2-->i={0}:gap={1}<br/>", I, Gap)); Response.Flush (); System.Threading.Thread.Sleep (1000); } }}
C # (ASP) multithreaded sample for working with multiple tasks at the same time