Ordering

Discussion in 'Java' started by nialltimpson, Mar 5, 2005.

  1. nialltimpson

    nialltimpson Guest

    Hey, simple question for yee all,

    Im writeing a threaded program but am a little confused in which order the
    methods are called, I know it goes from start() to run() but I also have a
    init() so when exactlywould this be called beforw or after start(),

    Sorry for my ignorance towards this topic,

    niall.
    nialltimpson, Mar 5, 2005
    #1
    1. Advertising

  2. nialltimpson

    HK Guest

    nialltimpson wrote:
    > Hey, simple question for yee all,
    >
    > Im writeing a threaded program but am a little confused in which

    order the
    > methods are called, I know it goes from start() to run() but I also

    have a
    > init() so when exactlywould this be called beforw or after start(),


    I remember that I was similarly confused when I looked
    at it the first time. Consider the run() method defined
    in interface Runnable as something which is *not*
    intimately related to threaded operation. It just defines
    an object which can do something meaningful when
    its run() is called.

    The start() method of Thread, on the other hand, is the
    time at which indeed at new thread of operations is
    branched off the main trunk. I guess it does some
    bookkeeping and finally calls run() of an enclosed
    Runnable object or of the Thread itself.

    If your Runnable has an init() method, I guess you want
    to call it before forking off the new thread of operations
    to set up things before the real work can start. This,
    however, depends strongly on what you actually want to
    do. I could as well imagine an init() which is called
    from run().

    Harald.
    HK, Mar 5, 2005
    #2
    1. Advertising

  3. nialltimpson

    nialltimpson Guest

    Thanks, very much for you reply, I appreceate it and im glad im not the
    only one baffled by this. I think I have a good just of what is going on,
    now all I have to do is understand what im going to do!!

    Thank again

    Niall.
    nialltimpson, Mar 5, 2005
    #3
  4. nialltimpson coughed up:
    > Thanks, very much for you reply, I appreceate it and im glad im not
    > the only one baffled by this. I think I have a good just of what is
    > going on, now all I have to do is understand what im going to do!!
    >
    > Thank again
    >
    > Niall.



    Put in the foremost section of your mind that if you haven't been coding in
    multiple threads for years that you are most definitely going to do many
    things wrong. There is no "good just (sic) of what is going on" regarding
    threads, until you've been at it for awhile.

    And most senior engineers are convinced that they've got a great handle on
    it, when they don't.

    How do I know this? I used to be contracted to fix multi-threaded java code
    and have seen many of the same simple mistakes, even by senior guys.


    --
    "So I just, uh... I just cut them up like regular chickens?"
    "Sure, just cut them up like regular chickens."
    Thomas G. Marshall, Mar 5, 2005
    #4
  5. nialltimpson

    Dotty Guest

    "nialltimpson" <> wrote in message
    news:...
    > Hey, simple question for yee all,
    >
    > Im writeing a threaded program but am a little confused in which order the
    > methods are called, I know it goes from start() to run() but I also have a
    > init() so when exactlywould this be called beforw or after start(),
    >
    > Sorry for my ignorance towards this topic,
    >
    > niall.


    If I remember right, your browser calls init() if it is an applet,
    and you are responsible for calling init() if it is an application.
    Dotty, Mar 6, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nospam
    Replies:
    13
    Views:
    612
    Guinness Mann
    Oct 7, 2003
  2. Craig Douglas

    Ordering FileInfo[] by date

    Craig Douglas, Jan 30, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    354
    Craig Douglas
    Jan 30, 2004
  3. =?Utf-8?B?RGlnZ2xlcg==?=

    Ordering items in ListBox

    =?Utf-8?B?RGlnZ2xlcg==?=, May 4, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    508
    =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=
    May 4, 2004
  4. Wayne M J

    DataGrid ordering

    Wayne M J, Jun 12, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    721
    Wayne M J
    Jun 12, 2004
  5. nbigaouette

    Z-Ordering (Morton ordering) question

    nbigaouette, Nov 5, 2009, in forum: C Programming
    Replies:
    2
    Views:
    2,149
Loading...

Share This Page