How do I use it?
Does anyone can give me an example or some links?
Thanks [:
How do I use it?
Does anyone can give me an example or some links?
Thanks [:
gavra.
It is fairly easy to google it
For linux google for pthreads. If you have a more specific question ask, don't have any specific link in mind...
If its for linux then here is one of many links
http://www.yolinux.com/TUTORIALS/Lin...ixThreads.html
google for "Windows Multithreading" gives 2.4 million hits, and the first five looks like very useful.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Ok.
I didn't understand the use of the parameter of thread and the parameters of the function that calls the thread (_beginthread), and why do I need to save the value that _beginthreads return?
gavra.
Huh?
In http://msdn.microsoft.com/en-us/libr...cb(VS.80).aspx
there is no "thread" parameter, so I can't explain that. I suppose you mean the "startaddress" parameter - that should be the function that contains what your thread does.
Stacksize tells what size the stack is for that function.
arglist is passed unaltered to the function specified as startaddress.
You don't HAVE to save that value - you need to check the value to see if you could create the thread successfully. I'm not sure if there's any function that takes the handle as a parameter.and why do I need to save the value that _beginthreads return?
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Look here:
http://www.codeproject.com/KB/thread...threading.aspx
I got confused @_@
To make it more simple I'll ask: "how do I create a new thread and how do I use this thread?"
gavra.
In the link above, this line creates a thread.
It implies that the returned value from _beginthread is actually a proper thread handle, and they use that to wait for the thread to finish.Code:handle = (HANDLE) _beginthread( ThreadProc,0,&val); // create thread
"using" a thread is simply just a matter of putting the right stuff in the thread-function. How you go about splitting a task into threads is a complicated subject, and without limiting the scope to something particular, it would take many many days to cover (there are probably dozens of PhD dissertations written on that subject alone).
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
ohh I don't understand this stuff (sorry)
I thought "_beginthread" just begin the thread and not creating.. @_@
gavra.
Threads can be considered tasks.
You create a task, then you execute it, pause it and resume it, or stop it.
To perform these tasks, you need to tell the one who is scheduling the tasks (Windows) what task you want to change something for. To do this, you pass the task's "handle." A handle is a number (from our point of view) that tells the one who schedules the threads what task we're talking about.
This translates exactly to what threads are about. The basics, anyway.
_beginthread returns that number or identifier which you need to identify that specific thread.
Multi-threading is not a simple task, nor a simple program architecture to work with. Perhaps, learn C and programming in depth before attempting such a feat.
That is just the name of the function, it actually both CREATES and STARTS a thread, where the work done by this thread is defined by the function given as "startaddress". By "creating" I personally mean creating the context (or environment) in which the thread executes, which include the OS represantion of a thread ('thread control block' or similar), stack (which is used to store parameters/arguments and return address when the thread is called and further calls to other functions within that thread). "Starting" means making the thread active to be able to run. In Windows (and most other multi-threaded environments) a thread can be created without actually starting it, but it's commonly that you actually want it to "start as soon as possible", so generally it is created and immediately set to "let it run" state.
As discussed in the other posts here, multi-threading is definitely not a simple subject, so if you are not fully familiar single-threaded programming, going multithreaded is not going to help - it adds a whole new dimension to what can and will happen in your program.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
I am traying to do something very simple..
no pausing and no resuming.
Why is that so hard?!
I'll try this ........ later, you may add simple examples..
thanks anyway.
gavra.