Re: Problem about multi-thread programming

2012-05-06 Thread Tongzhou Li
On Sunday, 6 May 2012 at 10:39:04 UTC, Chris Cain wrote: On Sunday, 6 May 2012 at 04:52:48 UTC, Tongzhou Li wrote: Thanks. Now it works fine with gdc, but still prints nothing with dmd. It seems that "cv[0].notify()" on line 29 affects nothing at all when using dmd2 :( I'm not exactly sure wh

Re: Problem about multi-thread programming

2012-05-06 Thread Chris Cain
On Sunday, 6 May 2012 at 04:52:48 UTC, Tongzhou Li wrote: Thanks. Now it works fine with gdc, but still prints nothing with dmd. It seems that "cv[0].notify()" on line 29 affects nothing at all when using dmd2 :( I'm not exactly sure what's going on for it not to work for you, but here's the

Re: Problem about multi-thread programming

2012-05-06 Thread David Nadlinger
On Sunday, 6 May 2012 at 04:54:44 UTC, Tongzhou Li wrote: Why? There's no data races... It's part of the protocol/contract/whatever you want to call it of condition variables as implemented in druntime. David

Re: Problem about multi-thread programming

2012-05-05 Thread Tongzhou Li
On Saturday, 5 May 2012 at 18:46:32 UTC, David Nadlinger wrote: On Saturday, 5 May 2012 at 08:45:21 UTC, Tongzhou Li wrote: I wrote: http://codepad.org/K4xQOREZ Besides the other things mentioned, you also need to lock the monitor associated with a condition before notifying/waiting (cf. a r

Re: Problem about multi-thread programming

2012-05-05 Thread Tongzhou Li
On Saturday, 5 May 2012 at 17:03:00 UTC, Chris Cain wrote: On Saturday, 5 May 2012 at 09:28:34 UTC, Tongzhou Li wrote: On Saturday, 5 May 2012 at 09:16:04 UTC, Kagamin wrote: What's in console? object.Error: Access Violation Expected output: 12341234123

Re: Problem about multi-thread programming

2012-05-05 Thread David Nadlinger
On Saturday, 5 May 2012 at 08:45:21 UTC, Tongzhou Li wrote: I wrote: http://codepad.org/K4xQOREZ Besides the other things mentioned, you also need to lock the monitor associated with a condition before notifying/waiting (cf. a recent discussion on the druntime list). David

Re: Problem about multi-thread programming

2012-05-05 Thread Chris Cain
On Saturday, 5 May 2012 at 09:28:34 UTC, Tongzhou Li wrote: On Saturday, 5 May 2012 at 09:16:04 UTC, Kagamin wrote: What's in console? object.Error: Access Violation Expected output: 12341234123 PS: Line 13 should be: write(Idx); By default, everything

Re: Problem about multi-thread programming

2012-05-05 Thread Tongzhou Li
On Saturday, 5 May 2012 at 09:16:04 UTC, Kagamin wrote: What's in console? object.Error: Access Violation Expected output: 12341234123 PS: Line 13 should be: write(Idx);

Re: Problem about multi-thread programming

2012-05-05 Thread Kagamin
What's in console?

Problem about multi-thread programming

2012-05-05 Thread Tongzhou Li
Hello everyone! I'm learning D and trying to write some sample code in D. I wrote: http://codepad.org/K4xQOREZ It compiles well with dmd 2.0.59, but I got an error when running: object.Error: Access Violation Any one help? Thanks.