Article Preview
Buy Now
FEATURE
Testing Preemptive Threading
Is It Really Faster?
Issue: 22.6 (November/December 2024)
Author: Marc Zeedar
Author Bio: Marc taught himself programming in high school when he bought his first computer but had no money for software. He's had fun learning ever since.
Article Description: No description available.
Article Length (in bytes): 29,296
Starting Page Number: 40
Article Number: 22606
Resource File(s):
project22606.zip Updated: 2024-10-31 23:47:18
Related Web Link(s):
http://www.xdevmag.com/browse/19.1/19104
http://www.xdevmag.com/browse/12.3/12310/
http://www.xdevmag.com/browse/17.1/17107/
Excerpt of article text...
Back in the days when computers only had a single processor, Xojo's cooperative multitasking was sufficient. But these days, all CPUs contain multiple cores. If you can harness those additional cores, your program can complete complex tasks much faster.
Xojo's first attempt to support multicore processing was via Workers (see "Working with Workers" in
xDev 19.1,http://www.xdevmag.com/browse/19.1/19104
). Workers are essentially separate console apps that are independent of your main program and can therefore run on their own core.While this approach is not unreasonable, Workers are not easy to use. Console apps themselves are extremely limited, and passing data to and from them via your main app is incredibly complicated. When testing Workers, I discovered that the overhead of dealing with them can often make them
slower than the traditional approach!My conclusion was that Workers are only useful in extreme situations.
But finally, with Xojo 2024 Release 3, we have true preemptive threads! These threads can run on their own core, if available, and while not immune to problems, they are
far easier to use than Workers.What Are Threads?
...End of Excerpt. Please purchase the magazine to read the full article.