THREADS_ALLOW will allow threads to run in the background, but you can only have one thread at a time access the Pike datatype tree, so only one interpreter thread will run at any specified time.
This uses two threads, two cores if your OS runs threads on different cores:
Pike v7.8 release 205 running Hilfe v3.5 (Incremental Pike Frontend) | > void test() { for (;;) { Image.Image i=Image.Image(1000,1000); | string s=Image.JPEG.encode(i); } } | > Thread.Thread(test); | (1) Result: Thread.Thread(1079527760) | > Thread.Thread(test); | (2) Result: Thread.Thread(1080490320)
Only minimal time is spent in the pike interpreter, and most of the time is spent "in the background" with the possibility for other pike interpreter threads to be run.
However,
| Pike v7.8 release 205 running Hilfe v3.5 (Incremental Pike Frontend) | > mapping m=([]); | > void test() { for (;;) m[random(100)]=random(100); } | > Thread.Thread(test); Thread.Thread(test); | (1) Result: Thread.Thread(1106815312) | (2) Result: Thread.Thread(1087379792)
Will only use one thread, since it's very interpreter-intensive. It needs to have the lock to be able to do that mapping operation, so no more than one core can be used. (And that makes the Hilfe interepreter break down to a halt. I'd consider that a bug, actually.)