www.digitalmars.com         C & C++   DMDScript  

D - [bug] 'synchronized' obviously wants to die...

reply h3r3tic <h3r3tic_member pathlink.com> writes:
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();
}
Apr 11 2004
next sibling parent "Kris" <someidiot earthlink.dot.dot.dot.net> writes:
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

 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();
 }

Apr 11 2004
prev sibling parent "Kris" <someidiot earthlink.dot.dot.dot.net> writes:
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

 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();
 }

Apr 18 2004