Question on the Thread

Hi all


Had a doubt while implementing threads, so I thought to do it erased before that I make progress. I have a method from where the new thread is called, and in the next line, I return statement.

Method() {}

Thread call ();
return the declaration;

}

What happens here? I want to say is that the parent process ends before the child process?

Thank you
Simi

user11138361 wrote:
I have exactly the same meaning

int foo() {}
Runnable r = new MyRunnable();
Thread t = new Thread (r);
t.Start ();
Return 1;
}

My question was if the child process runs then how will end the process (Px) parent?

There is no child process. You create a thread, not a process.

This point aside, I do not understand your question. The current thread and the new thread are totally independent of each other. Why wait we can't finish while the other is still ongoing?

Note also that the parent thread is NOT the same as this method foo(). The thread doesn't necessarily stop when the foo() method only. It can, however, and I don't know why you would think otherwise.

EDIT: My guess is that what you're really confused about is, ' how can end when foo() method one of its 'no' (in other words, the new thread) is running? The answer is that all its steps are made, even if the other thread is still ongoing.

stage of foo () of appeal t.start () is finished. This does not mean that the new thread has finished, however. The start() method says: "create a new, + independent + execution thread and turn it on." As soon as he does that, start() is done, and now the new thread is allowed to run (or run) regardless of the current thread.

Imagine that I have a list of chores: taking out the trash. Washing dishes; Show empty. This list is the foo() method. You are a new Thread object. After I wash the dishes, I tell you ' go to the store and buy some apples, milk, eggs, chicken and bread. " Let you do your work, and as soon as I told what to do, I continue with my duties. We do our work independently from each other, and I can't finish the chore on my list without waiting for you to come back on the store.

Edited by: jverd March 21, 2011 11:27

Tags: Java

Similar Questions

  • loading windows 7 on hp pavilion a810n feasibility - need to reply to the questions in the thread

    I got 1 response to my initial questions but I also followed questions that I have not received help with.   Also, here is the latest news.  I updated my old hp pavilion a810n 7 Edition windows xp home premium today.  Device Manager shows yellow exclamation points on ethernet controller and multimedia audio controller.  I ensure that I can't connect to internet because of these problems.  These two are fixed if I get some new material.  I gave the link, but I'm confused by all the different types of shows.   Please look at the thread and help me determine what I need and what should be the specifications so I can order the good part.  I'm new to this so any help would be greatly appreciated.

    Hello:

    I think you can use this audio driver.

    Audio: Accept the contract, download, unzip and install the driver first on the list.

    http://www.Realtek.com.tw/downloads/downloadsView.aspx?langid=1&PNid=23&PFID=23&level=4&Conn=3&DownTypeID=3&GETDOWN=false

    Ethernet: Try the file 6th on the list.

    http://www.Realtek.com.tw/downloads/downloadsView.aspx?langid=1&PNid=14&PFID=6&level=5&Conn=4&DownTypeID=3&GETDOWN=false

  • If you ask the question and then choose a solution, the thread will be closed or still can you ask more details?

    If you ask the question and then choose a solution, the thread will be closed or still can you ask more details?
    (sometimes, someone answers my question, and I want to mark it as the solution and am not yet quite ready for the thread be closed...)

    If you still experience this issue, you can return to this thread.
    But, you must clear the flag solved .

  • Questions typed into thread are placed after the signature?

    Everyone knows about this problem?

    You type a question in a particular thread, and it prompts you to connect. Once you have logged in, the issue disappeared.

    I find it rather annoying and hope it can be fixed soon.

    OS: 10.8.5

    Browser: Chrome (latest version)

    Well, if you sign in before starting a question (in fact, this field will be wind up as the topic of the thread, not the question), then you will not have this problem.

  • Stupid questions on the conservation of important calls on the FX application thread

    I'm working on a project that I have developed for over 6 months. I use JavaFX as the graphic side, but I take admission to a program called Max/MSP of music therapy, and I get a camera user input. These two things should run on threads separated since my FX application thread. So far, things have been involved in sweetness. I can handle things on the screen of my user input, and I have two communication work between my application JavaFX and Max. Now, however, I need to start drawing things actually executing. So far, virtually all manipulations aside just summer FX do translations. I now need to create, add and delete nodes children. So, I am of course an error saying not "on the FX application thread. I understand why it is not on this thread, and why it is a problem. So I made a few changes, so that calls that change the nodes on the stage, will be noted only the data and then make the changes later on the FX application thread. And then I encounter problems, questioning my own stupidity...

    I don't know how to get these calls on the FX application thread. I mean, it must be really easy. I'm obviously missing something. Or maybe I'm really tired and reflected on this during too long, or maybe the fact that it's been 6 months I wrote this part of the code. But I see my Mainstage class, which extends the Application. It has a function of departure, that brings up all my on screen-dads (nodes and other scopes), called stage.show ()... and then seems to end. When I did things as calling translate functions on my knots in my thread of user input, or my thread communication Max, things seemed to have worked. But now I think I might have been handling this evil from the ground up. It seems probable that I should have a 'main game loop' (it's not really a game, but still, same principle) where I can say the scene to update all the different nodes with the changes that have occurred since the last frame, and try out everything be updated in time for graphics render at a reliable pace. And yet, I simply don't see how to do this. I'm sure this should be obvious, but I am flat by cutting. And the lack of time begins to descend... Please, if you can point some average standard to avoid this common newb mistake if everything goes well, I would be very happy!
    -Jean

    I think that last one. Each change of a node that is currently part of the scene displayed should be accessible from the thread of FX.

    If the node is not attached to a scene, or the scene itself is not currently displayed, you can make changes on any thread.

  • Question of the UI thread

    OK, I hope it will be pretty easy to answer.  I am reading the Apress 'Development ahead of Blackberry' book and trying to follow through an example in Chapter 3.

    In this example, the user starts a separate thread to create and manage a Media Player object, however in the run() method, it tries to add a field (field VideoControl.initDisplayMode ()) to the screen without using invokeLater() or sync with the lock of the event.  I thought that I was uncomfortable with the fact that any changes to the user interface outside the user interface thread must use one of these two approaches, but that's shake me.  Can someone explain why this works?  Please find the below code snippet...

    Start is a method that is declared in the main class

    private void start() {}

    If (player == null) {}

    (new Thread() {}

    public void run() {}

    Code to create a player object, add a PlayerListener and put it in a State of REALIZATION

    VideoControl vc = (VideoControl) player.getControl ("VideoControl");

    If (vc! = null) {}

    Video of field (Field) = vc.initDisplayMode (VideoControl.USE_GUI_PRIMITIVE,

    "net.rim.device.api.ui.Field");

    Add (Video);

    }

    Player.Start ();

    }

    ({. start()});

    }

    }

    I have a problem in shape a bit above, so in case it is not clear, the (video) "add" call is inside an 'if' statement, which lies in the for the thread's run() method.

    Thanks in advance for any help!

    You have run the example? Because it should not operate unless they carried add() to do synchronization itself.

  • Under 'My Questions', to the question "cannot preview before printing in Windows Live Mail?", it shows a response, but when I click it, the answer is not there.

    Can't find an answer

    Under 'My Questions', to the question "can't preview before printing in Windows Live Mail?", it shows"last reply December 22, 2011 | by frank dem", but when I click it, it isn't there."

    Usermcw

    This is because it was deleted December 22, 2011. Looks that they cited just your original post, so she was removed because she had nothing to do with the thread.

  • Deleted question from the Forum?

    Is someone deleting messages from this forum?

    I asked a question on the backup of the computer and the question is no longer available?

    Markus

    Hello Huaraz,

    We will investigate the removal of the thread and I see that you have created a new thread here. I went with you on your question there as well.

  • Question about the strength of password

    (do not ask questions about the recovery of the password, so please do not report this thread)

    OK, I heard that the virus can change the password on a computer.

    But if you have a password very complicated (for example, one with a lot of numbers and other things), it will be more difficult/less likely for the virus to be able to change your password?

    Yes.  A strong password is, it is more difficult to crack.  For more information, see create strong passwords on the Microsoft online safety site. Boulder computer Maven
    Most Microsoft Valuable Professional

  • An error occurred when DNS was questioned about the resource record (SRV) service location used to locate a domain controller Active Directory (AD DC) for the domain 'HAMI. LOCAL ".

    An error occurred when DNS was questioned about the resource record (SRV) service location used to locate a domain controller Active Directory (AD DC) for the domain 'HAMI. LOCAL ".

    The error was: "an existing connection was to be closed by the remote host".
    (0 x 00002746 WSAECONNRESET error code)

    The query was for the SRV record for _ldap._tcp.dc._msdcs. HAMI. LOCAL

    Hello

    Your question of Windows 7 is more complex than what is generally answered in the Microsoft Answers forums. It is better suited for the IT Pro TechNet public. Please post your question in the Forums TechNet Windows 7 Technet.

    Here is the link:
    http://social.technet.Microsoft.com/forums/en-us/w7itpronetworking/threads

    Hope this helps

  • Call Dialog.ask in the Thread Run method

    "in I want to call Dialog.alert and using following code but its exception to throw the wire.

    "Exception occurs java.lang.RuntimeException: pushModalScreen called by a thread of non-event."

    synchronized (Application.getEventLock ())

    {

    if (Dialog.ask ("catalog is obsolete. You want to keep it? ", choices, select, select [0])(==1)"

    {

    Run the required functionality

    }

    }

    pls help me

    I keep saying this, so forgive me of repeating myself, but:

    synchronized (Application.getEventLock ()) {}

    should only be used when nothing else will work for you or you make a very simple, very fast UI update.

    A Dialog.ask is not very fast!

    In this case, you have several options, but the most obvious solution is to ask the question before starting the Thread.  So, if that is your treatment

    Thread catUpdateThread = new Thread() {}

    public void run() {}

    Dialog.ask (...)

    Other treatments

    }

    }

    catUpdateThread.start ();

    What should do the same and works OK. :

    UiApplication.getUiApplication.invokelater (new Runnable() {}

    public void run() {}

    Dialog.ask (...)

    If (result == Yes) {}

    Thread catUpdateThread =...;

    catUpdateThread... Start();

    }

    }

    });

  • Another Question regarding the IPC in the BB platform (secure process for RuntimeStore)

    In my scenario,.

    Process one will constantly be voicemails from somewhere and put it in a table in a RuntimeStore, named _store.

    B process, there is a thread T will waitFor the ID of the table in the _store. If succeeds, then copy to another location, i.e.,.

    persisting an object and then eaten after this, the thread will remove the ID of the table in the _store.

    I wonder if it is safe for both processes simultaneously access the _store.

    Wrote in the store. B is read and write to the store.

    If someone could help?  Very well appreciated.

    I am a bear with very little brain and can never remember the right way of doing things.  I'm sure that someone will take the holes in what follows and suggest the best ways and it would be fantastic.

    I think there are two issues here:

    (a) simultaneous access

    (b) persistence

    (a) the simultaneous access to an object in the persistent store are no different from any object, they are located in PersistentStore, RuntimeStore or RAM.

    Thus, for example, let's say we have a vector in PersistentStore, we use just like a queue to a single server (then only add to the tail and remove the head), with a separate 'lock' in RuntimeStore object.  Synchronize us on the lock object before we add an element, or remove an item, our access is perfectly safe

    (b) persistence

    Yes I agree, this aspect is not clear.  I always thought I want to commit an object placed partially updated, so in this example, would make the validation in the context of add or remove the treatment.

    Of course, things become a little more complicated if you start to talk about data updated in the queue, but I do not think that these problems are related to PersistentStore as a result, I think that these are issues of a general nature and there is probably many places on the web where are discussed different mechanisms to make sure that it works well.

    A few other points:

    (1) I understand that the treatment of validation is "atomic" on the BlackBerry and the "wound", so if you make an object you will persist all changes to this object. Usually, I maintain a collection that is associated with an Application for validation, points specific in the treatment of requests to ensure that the data associated with an application conform to the battery be fired immediately after a commit.

    (2) you can see updates of persistent objects, even if they are not posted.  These changes will be lost if they are not posted. So if you have a line like the one above, and two Clients add entries in the queue without committing, the server see the two entries in the queue until the battery is removed.  When the server restarts, the two went.

    Does that answer the question?

  • Client/server Push application: how to run the thread listening on basis of the necessity?

    Hello

    To receive the broadcast content from the server, a thread of listening to the need to run in the back ground on the BlackBerry.

    For a client application to receive the server put grows optimally updated, what is the best way?

    1. run the thread listening on the installation of the client application using auto-run on start up?

    What happens to the thread if there are reboot the device? The listener would start again?

    2. run the thread listening on the launch of the client application?

    (or)

    3. is there a way to run the thread to listen according to the need, when there is dissemination of the server, as some notification (called by server) to the client that there is dissemination of the server and the client then begins the listening thread?

    Please contribute your valuable and suggest most commonly followed and best practices.

    Kind regards

    Suresh.

    you don't know. If it's a good thing to do is another question.
    You can use an inboxlistener to receive an email or even a text message with a command to start the pushlistener. But why you want to do something like that? listening on a port, there's nothing that drains the battery.

  • Quick questions on the CC student kit

    I tried to search the FAQ or customer support, but couldn't really find something where I could just after a small question about the recognition of things so... If you know what I'm looking for already feel free to guide me where to look for it.

    I was therefore interested to the kit of the CC student which includes all applications a year. (think it says about 2000 Swedish kronor, which is roughly around 200 euros).
    And so I saw was one of the best idenfications using your email from the school which includes stuff like ".edu".  The problem is that I have one, but only use us it as a registering or connect the credentials for our orders online. If this isn't an email that I can receive emails since then, so I'm just wondering if all I had to do was use it as a registering or the legitimacy that I am a student, or if it must be signed using this specific e-mail. I could talk about technology in school and get it set up, but he mentioned that it is somewhat lengty and or boring process then advised me to see if it was as a registering first egible before again us.

    If you know where I could have found this info in FAQ or similar stuff please let me know, otherwise I'd like a few quick answers to this. See you soon!

    Hi Nyom,

    I order to buy creative cloud subscription, you must have a valid email ID where you can receive by e-mail sent by Adobe.

    Given that the address you have is not where you can send or receive e-mails, you can go ahead and use a personal e-mail ID.

    If you purchase the subscription using an ID, you may be asked to provide additional proof of eligibility.

    Please see the shared document:student software discounts, the eligibility of the student. Adobe

    Please update the thread in the case of all other applications.

  • Not able to post a question on the Forum SQL

    Hello

    I'm trying to post a question on the SQL forum, tried 2 times, but it does not appear.

    I am able to see my question on my Inbox, but this issue does not appear in the SQL forum.

    This is the link to my thread: transpose columns in lines

    Please help me,

    Kind regards

    Jitendra

    Indeed, it is a loophole.

    If you go to SQL and then click on the 'Content' link, you will see that need you the space of PL/SQL and if you post a discussion there, it will appear in the list of threads space the SQL and PL/SQL.

    ---

    Ping moniquevdb-Oracle and Oracle-hocinebelatreche to ask that they please untangle this loophole (or someone who can ping).  I can confirm that, following steps of Jitendra, people are still able to create threads in the old list of SQL thread when they should go to list of PL/SQL threads.

    Essentially, this means that the messages of the people will be lost to most of the community.

    I don't always put the purpose of actually having a separate SQL space, as it doesn't really seem to offer much to the what it was associated with the PL/SQL space.

Maybe you are looking for

  • can not see the text to type to confirm that I'm not a robot!

    I'm trying to set up sync, everything works fine until I get to the page "prove that you're not a robot."I can't see any text to type, so I can't continue.Help, please! p.s. I am not a robot, promise!

  • NVidia for Pavilion 500

    I have a HP Pavillion 500, product number: h6u14aa #aba I'm wanting to get a graphics card NVidia for it, but before I dish on the dough, I want to make sure I get one that will work with my PC. How would this work: http://www.bestbuy.com/site/asus-g

  • Not receive Gmail notifications after update

    Hey guys, I got a problem with Gmail after update of the Volte. For some reason any I was not receive notifications from Gmail. I have to go into Gmail and refresh in order to get all that is useless since I'm already in the application manually. Eve

  • Vista can not download updates?

    Whenever I have disable my computer and Vista tries to update before you stop, OR when I go to the windows update area when it stops not and try to get it to update, it is stuck at 0% and does nothing. When I try to do stop updating in the center of

  • Microsoft puzzle crazy me - but not in a good way

    I have Microsoft surface rt and use the application of Jigsaw.   every time I do a puzzle, the application crashes when it's over, and I am not given the option to return to the menu puzzle.  I have to turn off my surface and restart it to get the op