C
Carly
Hi,
I 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
I 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