Search:

Type: Posts; User: Norm

Search: Search took 0.09 seconds.

  1. Replies
    15
    Views
    1,604

    [SOLVED] Re: Help with SYNCHRONIZED

    Glad you got it working.
  2. Replies
    15
    Views
    1,604

    [SOLVED] Re: Help with SYNCHRONIZED

    The CPU is too fast. You need a way to slow down the threads so other threads can catch up.
    With your very short methods, how can one thread catch the other? The first thread will be done before the...
  3. Replies
    15
    Views
    1,604

    [SOLVED] Re: Help with SYNCHRONIZED

    Do you understand how fast your computer is?

    Please explain what you mean here?

    I think it is working the way it is programmed.
  4. Replies
    15
    Views
    1,604

    [SOLVED] Re: Help with SYNCHRONIZED

    Yes, probably not.
    Your computer is too fast. Each thread completes before the next one starts.
    Put some work into the methods that would slow the thread down and allow other threads to catch up.
  5. Replies
    15
    Views
    1,604

    [SOLVED] Re: Help with SYNCHRONIZED

    Yes the new code would keep the incrementing and getting the value in synch.


    No, in any one thread, the call to getNum() is after the call to addToNum(). That would not be changed.
  6. Replies
    15
    Views
    1,604

    [SOLVED] Re: Help with SYNCHRONIZED

    The threads are NOT locking the resource between the calls to the two methods.

    Try debugging the code by adding printlns to the two methods that show the value of num and the name of the thread...
  7. Replies
    15
    Views
    1,604

    [SOLVED] Re: Help with SYNCHRONIZED

    Why not? Please explain why you think that.
    The OS determines when each of the threads executes. Is there an order of execution that will allow different threads to get the same number back from...
  8. Replies
    15
    Views
    1,604

    [SOLVED] Re: Help with SYNCHRONIZED

    Please post the output from the program that shows the problem.

    What would be the results if all the threads called addTonum() and then they all called getNum?
Results 1 to 8 of 8