Thread overview |
---|
April 11, 2004 [bug] 'synchronized' obviously wants to die... | ||||
---|---|---|---|---|
| ||||
this program never finishes. it prints foo foo and its window remains open, eating all available CPU power. if only one call to foo is made in main, everything is fine. so it is when the 'synchronized' statement is removed. tested on dmd 0.82, winxp sp1. void foo() { synchronized { printf("foo\n"); } } void main() { foo(); foo(); } |
April 11, 2004 Re: [bug] 'synchronized' obviously wants to die... | ||||
---|---|---|---|---|
| ||||
Posted in reply to h3r3tic | Typically, one would need an object to synchronize upon, even if it's the class object where the synchronized keyword appears within. For example, this version works as one might expect: static Object o; void foo() { synchronized (o) { printf("foo\n"); } } void main() { o = new Object(); foo(); foo(); } I wonder if synchronized is even meant to parse for 'static' usage per your example? The online-reference section on "statements" does appear to indicate this is supported though ... SynchronizeStatement: synchronized Statement synchronized ( Expression ) Statement - Kris "h3r3tic" <h3r3tic_member@pathlink.com> wrote in message news:c5b4bi$k2i$1@digitaldaemon.com... > this program never finishes. it prints > > foo > foo > > and its window remains open, eating all available CPU power. if only one call to > foo is made in main, everything is fine. so it is when the 'synchronized' statement is removed. tested on dmd 0.82, winxp sp1. > > void foo() > { > synchronized > { > printf("foo\n"); > } > } > > void main() > { > foo(); > foo(); > } > > |
April 18, 2004 Re: [bug] 'synchronized' obviously wants to die... | ||||
---|---|---|---|---|
| ||||
Posted in reply to h3r3tic | Walter, Is synchronized supposed to work with static methods? Currently, it really does produce some very odd process-termination behavior ... - Kris "h3r3tic" <h3r3tic_member@pathlink.com> wrote in message news:c5b4bi$k2i$1@digitaldaemon.com... > this program never finishes. it prints > > foo > foo > > and its window remains open, eating all available CPU power. if only one call to > foo is made in main, everything is fine. so it is when the 'synchronized' statement is removed. tested on dmd 0.82, winxp sp1. > > void foo() > { > synchronized > { > printf("foo\n"); > } > } > > void main() > { > foo(); > foo(); > } > > |
Copyright © 1999-2021 by the D Language Foundation