|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Threading QuestionI have the following code: Imports System.Threading Module Module1 Sub Main() Dim mydel As New WaitCallback(AddressOf Showmytext) ThreadPool.QueueUserWorkItem(mydel) ThreadPool.QueueUserWorkItem(mydel) ThreadPool.QueueUserWorkItem(mydel) Console.Read() End Sub Sub Showmytext(ByVal state As Object) Dim mystr As String = CType(state, String) Console.Write(Thread.CurrentThread.ManagedThreadId) Dim i As Integer Dim j As Long For i = 1 To 10000 j = 0 j = 10000 * 123456 Next Thread.Sleep(1000) Console.Write(j) End Sub End Module All my code runs in the SAME thread and runs... synchronously meaning it ways for the first for i-----sleeps then writes the result on the console , moves to the next.... etc. Please somebody explain why. Thanks, Carly "Carly" <carl.j***@hotmail.com> wrote: I just ran your code and it used two threads in the pool.>All my code runs in the SAME thread and runs... synchronously meaning >it ways for the first for i-----sleeps then writes the result on the >console , moves to the next.... etc. >Please somebody explain why. Then I increased the Sleep to Sleep(10000) and it used three threads in the pool. -- Lucian
cut, copy, and paste
Reservation algorithm Sending Email via VB.Net displaying resource file as Help Multithreading with DirectoryServices Sql 2005 and vb 2005 question? Object Type Conversion Error How to collect the data from input created by document.write() in ASP.NET? What would be a good way to add image files to my solution Stopping Windows Service with Thread |
|||||||||||||||||||||||