xroot Posted February 25, 2009 Share Posted February 25, 2009 What I have learned about Multihreading is the following:All processes have at least one thread of execution, which is called the main thread. The mainthread is created when your program begins. In a multithreaded program, the main thread createsone or more child threads. Thus, each multithreaded process starts with one thread of executionand then creates one or more additional threads. In each thread represents a single logical unitof work or activity.This Multithreading allows the threads to exist within the context of a single process.These threads share the main process, resources and are able to execute independently.All the threads can run at the same time without interfering with each other.A multithreaded process with two or more threads executing in time clearly showing that the threadsexecute separately and execute mutually exclusively in time is multithreading.My script shows the above criteria to be true. I finally know that Autoit3 can multithread. mutiThreads.zip Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 25, 2009 Moderators Share Posted February 25, 2009 SetTimer API is not multi-threading. It shares resources from the calling thread. To test it, run a simple While/Wend loop that does some kind of counting, then do a SetTimer API call before that loop that also has a loop that counts. You will find that you have many less cycles in your main loop when using SetTimer than you would not using it. Now don't get me wrong, I use SetTimer all the time, it does have its place... but I only use it when my scripts/loops are not speed sensitive. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
cppman Posted February 26, 2009 Share Posted February 26, 2009 All the threads can run at the same time without interfering with each other.A multithreaded process with two or more threads executing in time clearly showing that the threadsexecute separately and execute mutually exclusively in time is multithreading.That is not entirely true, because in a way they do. When you only have one CPU, each thread is given a certain amount of time (or instructions) to execute. After that thread is done being executed, the next thread gets a turn, and so on. The only reason this works is because just before the next thread is given a chance to execute, the OS has to save the state of the current thread (most of the registers). When that thread gets a chance to execute again, the state is restored. The same is true for multiple cores (and multiple CPUs). The only difference is, you'll have multiple processors doing what I just described above (roughly). And, if you are using a multithreaded operating system (like Windows or Linux), then this is happening every single microsecond (even less) - seems like a lot of speed loss and interruption of other threads. Miva OS Project Link to comment Share on other sites More sharing options...
WolfWorld Posted February 26, 2009 Share Posted February 26, 2009 Nop it look like but no like SmOke_N said it WILL stop what you are doing and execute the function. Autoit can only be multithreading but not thread-safe at all. Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
bienmexicano Posted March 31, 2009 Share Posted March 31, 2009 (edited) well i'm kinda noob with the scripts, so i have question: from where is the function "Thread_MsgLoop" beeing call?, i cant figure out, the script works perfectly but i wanna learn his logic to use it with a project that requires something near to multithread. tnx in advance. Edited March 31, 2009 by bienmexicano i love to draw so Go here!!!!!!! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now