Search:

Type: Posts; User: Norm

Search: Search took 0.13 seconds.

  1. Replies
    18
    Views
    2,376

    [SOLVED] Re: Threads - I need some explanations

    Not sure what the "real world" is. Here is some code I've used to start some threads:


    Thread t1 = new Thread(new Runnable() {
    public void run() {
    ...
  2. Replies
    18
    Views
    2,376

    [SOLVED] Re: Threads - I need some explanations

    No. Usually nothing is static except for the main() method.
  3. Replies
    18
    Views
    2,376

    [SOLVED] Re: Threads - I need some explanations

    Create a new thread with its run() method that calls the methods that you want to execute on that thread.
  4. Replies
    18
    Views
    2,376

    [SOLVED] Re: Threads - I need some explanations

    Put the calls to the methods inside separate run() methods and create and start threads as is done in post#1
  5. Replies
    18
    Views
    2,376

    [SOLVED] Re: Threads - I need some explanations

    That was explained in post#6. first method must finish before second method can start.
    The two methods are executing on the same thread.
  6. Replies
    18
    Views
    2,376

    [SOLVED] Re: Threads - I need some explanations

    Please explain what doesn't happen.
    Add the value returned by the System class's currentTimeMillis() method to all printed messages so you see when they were executed.
  7. Replies
    18
    Views
    2,376

    [SOLVED] Re: Threads - I need some explanations

    Add some more println statements where the threads are created that print out messages at each step in the execution of the main method that show when when each statement is executed.

    Are you...
  8. Replies
    18
    Views
    2,376

    [SOLVED] Re: Threads - I need some explanations

    A thread starts executing the run() method. The run() method can call any other method it wants.

    The OS determines when each thread gets to execute. The code in a thread must do something to...
  9. Replies
    18
    Views
    2,376

    [SOLVED] Re: Threads - I need some explanations

    If you don't want a method to execute on the run() method's thread don't call it from the run() method. Any method called from the run() method will execute on that thread. Any methods that the...
Results 1 to 9 of 9