News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

multithreading

Started by AssemblyBeginner, September 09, 2006, 06:03:30 PM

Previous topic - Next topic

AssemblyBeginner

hi
       i want to make my app multithreaded.i never go before this concept.i have a list of some urls,now i m visiting these urls sync
      and sequentially thru socket.i want to acheive this thing in multithreaded i.e visiting async and run 5 threads of different
      urls at a time.

      plz guide me how i acheive this thing,how i design a flow and which funcs help me to acheive this thing.i read some funcs
      regarding multithreading(CreateThread) may this help me in this thing.

      plz suggest me the site that helpz me in understanding multithreading.if some one guide me here with small snippets
      commented i m greatly thankful to him.

regards
AsmBeg
     
     

James Ladd

The great source of information for threading in Win32 is the book "Multithreading Applications in Win32".
It covers all the techniques and gives example programs.

AssemblyBeginner

 don't know that i have use CreateThread func correctly.the result is not correct may be the urldownload2file takes time???

invoke CreateThread ..,MyThread1..
invoke CreateThread ..,MyThread2..
invoke CreateThread ..,MyThread3..
invoke CreateThread ..,MyThread4..

Mythread1 proc
urldownload2file url1..
ret
Mythread1 endp
  ....
  ....
Mythread4 proc
urldownload2file url4..
ret
Mythread4 endp


plz guide me how to use in correct way

dicky96

Hi  Assemblybeginner

From another beginner - I didn't believe it (as I thought it was gonna be really difficult) but multithreading is actually dead easy  :U

Just write a subroutine/procedure to do whatever you need...... then instead of using call or invoke you use that createthread thing you mentioned, with the address of your procedure.

After that your procedure is happily running in the background.  I seem to find the worker thread is generally gonna be some task that runs in a continuous loop until you want it to finish - otherwise why use multithreading  :wink

Iczelion has a tutorial on this and I thought it was really useful - make sure you read it

Following that tutorial, the best method of implementing this seems to be making the "worker" thread send a custom windows message to your main procedure to signal it has sometihing ready for you to process, then using a global variable (flag) to tell the worker thread what to do (terminate etc)  In your worker thread just make sure you chack for the value of this flag.

I'm sure lots of gurus here can help you more, but at least in the above sense I found multithreading a lot easier than I find dealing with the Windows API

So from one beginner to another I wish you good luck

AssemblyBeginner

thks dicky96 for replying
among experience beginner helps beginner  :U
great job