Is this correct? Sorry, i have no java skills, but we have to take this course :(
So pls help me ;)

March 29th, 2013, 12:02 PM

Norm

Re: Help wanted using wait() and notify()

To test the code for the task, you'll need two threads: one to wait and one to do the notify after world is set true.

The wait and the notify methods must use the same object when called.

How did you get this assignment if you have no java skills? This is not a beginning programmer problem.
What have gotten in class about using the wait and notify methods and about threads?

March 29th, 2013, 12:36 PM

sandramo

Re: Help wanted using wait() and notify()

Yes i know, this is usually not for beginners. but i have to take this course, giving me no alternative. the course is about parallel programming...
i got the examples from the lecture notes and tried to understand it. i read much in the web, so that was my result.

so what i didn't get: is my code wrong? I found a similar example and tried to transform it to my problem...

So please help me. When you have a good page for me, where i can get the basics, i would really be happy. i have to pass this course, however...

March 29th, 2013, 12:57 PM

Norm

Re: Help wanted using wait() and notify()

Do you have code to test with? A class that has a main() method.

March 29th, 2013, 01:03 PM

sandramo

Re: Help wanted using wait() and notify()

no, thats what you meant with

Quote:

Originally Posted by Norm

To test the code for the task, you'll need two threads: one to wait and one to do the notify after world is set true.

right?

March 29th, 2013, 01:08 PM

Norm

Re: Help wanted using wait() and notify()

How do you test the code you have written? Can you post some code here that will call the methods for testing?

March 29th, 2013, 01:17 PM

sandramo

Re: Help wanted using wait() and notify()

actually i am not testing the code, don't know how to do. thats the reason why i am here. in the course the teacher gives many examples, one in java, the next in c,...
we didnt get any introduction, cause the course is normally not for beginners like me. so what i did until now: i read many on the web, actually beginning with my first hello world project. so maybe it could be possible, that you tell me, how the main method looks like and i could test it in eclipse?

my solution would be to call in main the act() method -> nothing happens
call the maketrue() followed by act() -> an output appears

March 29th, 2013, 01:19 PM

Norm

Re: Help wanted using wait() and notify()

The testing code needs to start two threads.
The first will wait for the variable to be set.
The second will set the variable and notify those waiting.