https://issues.dlang.org/show_bug.cgi?id=2043
Artem Borisovskiy <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] Severity|normal |major --- Comment #9 from Artem Borisovskiy <[email protected]> --- I write a simple app that reads a binary log file, decrypts the messages in parrallel and prints them when all the decrypting threads are finished. Here's a piece of my code: -------------- auto workers = new ThreadGroup; int i; foreach (group; logEntries.chunks(averageChunkSize)) () { auto data = group; auto ii = i; auto workerThread = new Thread( { writefln("[%s] %s", ii, data.length); }); workers.add(workerThread); workerThread.start; ++i; }(); workers.joinAll; -------------- As you can see, I tried to use hack from the code above, but it didn't help until I created "data" and "ii" variables. Just using "i" and "group" gives wrong results, just as described by Bruno. The same code works perfectly in Java, and it should in D, because it's the way closures work. Please, fix this bug, it's real PITA and it's 6 years old after all. --
