Search:

Type: Posts; User: bassie

Search: Search took 0.09 seconds.

  1. Replies
    14
    Views
    1,504

    Re: Thread synchronisation help!

    ah there is nothing missing I made a mistake there. I am finding this way too difficult to grasp so I am going to focus on using synchronisation with monitors instead. Thanks for the help!
  2. Replies
    14
    Views
    1,504

    Re: Thread synchronisation help!

    So I edited run() to help me try and trace what the program is doing at each step;



    public void run()
    {
    System.out.println("Begin of run("+num+")");
    for (int k=0; k<2000000; k++)...
  3. Replies
    14
    Views
    1,504

    Re: Thread synchronisation help!

    Thanks for the advice norm, but this actually looks hopeless. The numbers are printed out in random order regardless of how they are ordered in the main method or what priority I set them, if I am...
  4. Replies
    14
    Views
    1,504

    Re: Thread synchronisation help!

    so it turns out I was looking at it wrong, the code is slightly different (this book is really confusing), but the revised version still doesn't work.
    The textbook claims it will print out...
  5. Replies
    14
    Views
    1,504

    Re: Thread synchronisation help!

    Do you mean the currentThread method? I don't understand how I am meant to be using it...

    Should I some how be referencing the run () method from NumberPrinter.java in the main() method of...
  6. Replies
    14
    Views
    1,504

    Re: Thread synchronisation help!

    Thanks!

    I looked it up and it appears that the setPriority method is defined in the Thread class.
    I tried calling it using Thread.sePriority() but got an error for trying to call a non-static...
  7. Replies
    14
    Views
    1,504

    Re: Thread synchronisation help!

    Well the book seems so be suggesting that setPriority() is part of the interface Runnable, or at least that I can use it in this situation by simply calling it. Am I misunderstanding this entirely?
  8. Replies
    14
    Views
    1,504

    Thread synchronisation help!

    Hi whenever I try to run Numbers.java I get;

    NumberPrinter.java:8: error: cannot find symbol
    setPriority(n);
    ^
    ...
Results 1 to 8 of 8