I need help about threads

Hi!, I need to know how can i do that a father thread have acces to the son thread's methods or how a son thread can to notify at father any event?
thanks

look at the thread tutorial, it covers nofity, notifyAll, etc. Also check out the Thread class API...

Similar Messages

  • Need help about Thread issue

    Given from scjp
    1.public static void main(String[] args) {
    2.        NameRunnable nr = new NameRunnable();
    3.        Thread t1 = new Thread(nr);              
    4.        t1.start();
    5.        t1.join();                   
    }There are some questions which i made up myself to test how i understand about the thread issue and I really need some experts to confirm about it.
    Question 1: At line 3, how many threads we have now ?
    my answer is
    there are 2 threads. the first one is main thread and the second one is t.
    I am not sure about the t thread because in the book, they indicate that after instantiating the thread,
    we just have a thread object but not a true thread.
    Question 2: At line 4, after t1.start(), which thread will be executed first.
    My answer is
    we dont know because it depends on the scheduler.
    Question 3: what t1.join() does ?
    my answer is
    blablabla.What I am thinking is t.join() joins the current thread to the end of t so that when t finishes the current thread can run again. However, which one is the current thread now. That is why I am stuck
    Please help me. I appreciate
    Edited by: newbie on Nov 25, 2010 4:46 PM
    Edited by: newbie on Nov 25, 2010 4:47 PM
    Edited by: newbie on Nov 25, 2010 4:49 PM

    newbie wrote:
    Given from scjp
    public static void main(String[] args) {
    NameRunnable nr = new NameRunnable();
    Thread t1 = new Thread(nr);              
    t1.start();
    t1.join();                   
    }There are some questions which i made up myself to test how i understand about the thread issue and I really need some experts to confirm about it.
    Question 1: At line 3, how many threads we have now ?
    my answer is
    there are 2 threads. the first one is main thread and the second one is t.
    I am not sure about the t thread because in the book, they indicate that after instantiating the thread,
    we just have a thread object but not a true thread.
    Don't use code blocks for prose. It won't autowrap and can lead to display problems if a line is too long.
    Which is line 3?
    What do you mean by "how many threads to we have?" Do you mean how many Thread objects exist, or how many threads (lower case "t") are executing.
    After you have called t1.start(), there are at least 2 threads executing--the main thread, and the one you started. I say "at least" because the JVM has some administrative threads of its own.
    Question 2: At line 4, after t1.start(), which thread will be execute first.
    My answer is
    we dont know because it depends on the scheduler.
    Correct. And don't think of one executing "first." They can take turns, or they can both execute at the same time (if you have a multicore or multi-CPU machine).
    Question 3: what t1.join() does ?
    my answer is
    blablabla.What I am thinking is t.join() joins the current thread to the end of t so that when t finishes the current thread can run again. However, which one is the current thread now. That is why I am stuck
    Please help me. I appreciateDid you read [url http://download.oracle.com/javase/6/docs/api/java/lang/Thread.html#join()]the docs for join()? They tell you exactly what it does. If you don't understand after reading, post again.

  • Need help about Hidden Markov Model model

    I want to make classification for EEG signal using Hidden Markov Model
    algorithm based on neural network.
    plz need help about how to implement this algorithm using LABVIEW.
    if not I want another thing to make classification.
    any one know information about this topic, send me a reply
    thanks

    Have you derrived the HMM that you want to implement?
    If so, post the algorithm and we can provide comments on how to implement it using LabVIEW.
    Message Edited by Ray.R on 04-12-2010 12:54 PM

  • Need help about ref cursor using like table

    Hi Guys...
    I am devloping package function And i need help about cursor
    One of my function return sys_refcursor. And the return cursor need to be
    join another table in database . I don't have to fetch all rows in cursor
    All i need to join ref cursor and another table in sql clause
    like below
    select a.aa , b.cc form ( ref_cursor ) A, table B
    where A.dd = B.dd
    I appeciate it in advance

    My understanding is that you have a function that returns a refcursor and is called by a java app.
    Because this is a commonly used bit of code, you also want to reuse this cursor in other bits of sql and so you want to include it like table in a bit of sql and join that refcursor to other tables.
    It's not as easy as you might hope but you can probably achieve this with pipelined functions.
    Is it a direction that code should be going down? yes, eventually. I like the idea of pulling commonly used bits of code into a SQL statement especially into the WITH section, provided it could be used efficiently by the CBO.
    Is it worth the effort given what you have to do currently to implement it? possibly not.
    what else could you do? construct the sql statement independently of the thing that used it and reuse that sql statement rather than the refcursor it returns?
    Message was edited by:
    dombrooks

  • Need help about boot SUNFIRE V120

    Hi all....
    I need help about how to change boot from boot net to boot disk....
    after i installed sun solaris 10 at my sunfire v120, then reboot the machine ... this sunfire still boot from net not from disk...
    can i change it?
    please i really need help ....
    thanks

    If its booted, try "eeprom boot-device=disk"
    If your at the OBP, "setenv boot-device disk".
    If that doesnt work check the value of "diag-switch?".
    It could be booting off the the diag-device instead

  • Need Help about 3D and revolving in illustrator

    I really need help about 3D, Please tell me that How i create 3D in illustrator
    i want to revolve text or shape around any object like this, any plugin? or other software required for this?
    if somebody know this it will be really help full
       http://rcgrafix.fizwig.com/1452732-large.jpg    
       http://rcgrafix.fizwig.com/1384370-large.jpg
       http://rcgrafix.fizwig.com/1062180-large.jpg
    Thanks
    Arsi

    if links are not working try Copy and paste it in to your browser address bar
    thank you

  • Need help about the SHA Message Digest ? & what is use of Message Diagest ?

    need help about the SHA Message Digest ? & what is use of Message Diagest ?
    1>i have one program of making message digest
    2>which requires two files name
    3>one for input like txt
    4> second is out put file of message digest
    can any one tell what is the use of second generated file .

    MessageDigest md = MessageDigest.getInstance("SHA");
    FileInputStream fis = new FileInputStream(args[0]);
    byte[] b = new byte[1024];
    int readed = -1;
    while((readed = fis.read(b)) > 0)
         md.update(b, 0, readed);
    fis.close();
    FileOutputStream fos = new FileOutputStream(args[1]);
    byte[] d = md.digest();
    StringBuffer sb = new StringBuffer();
    for(int i = 0; i < d.length; i++) {
         String str = Integer.toHexString(d[i] & 0xff);
         sb.append(str.length() < 2 ? "0" + str : str);
    fos.write(sb.toString().getBytes());
    fos.close();

  • Need help about 1015

    need help about 1015 it says connect iphone to itunes on screen i did it but it doesnt work and says unexpected 1015

    Try restoring it: Make sure you are following the instructions in this procedure to the letter.  Here they are, with emphasis on some easily overlooked requirements:
    Disconnect the USB cable from the iPhone, but leave the other end of the cable connected to your computer's USB port.
    Turn off the device: Press and hold the Sleep/Wake button for a few seconds until the red slider appears, then slide the slider. Wait for the device to turn off.If you cannot turn off the device using the slider, press and hold the Sleep/Wake and Home buttons at the same time. When the device turns off, release only the Sleep/Wake button.
    Continue pressing and holding the Home button while you reconnect the USB cable to the device. The device should turn on.
    Note: If you see the "low battery" screen, let the device charge for at least ten minutes to ensure that the battery has some charge, and then start with step 2 again.
    Continue holding the Home button until you see the "Connect to iTunes" screen. When this screen appears (iTunes icon and USB connector) release the Home button.
    If necessary, open iTunes. You should see the "recovery mode" alert ("iTunes has detected a phone in recovery mode").
    Use iTunes to restore the device.
    If you do not see the "Connect to iTunes" screen, try these steps again.
    If you see the "Connect to iTunes" screen but the device does not appear in iTunes, see this article and its related links.
    If you have backed up the iPhone in the past, select the device in iTunes and choose "restore from backup".

  • Hi, Need help about ios7 upgrade, after this upgrade I cannot watch youtube or any video with my Ipad,

    Hi, Need help about ios7 upgrade, after this upgrade I cannot watch youtube or any video with Ipad, and Iphone as well
    I think my wireless rooter's setting has some problem but cannot found anything to solve,
    I can watch if there is another wireless network , I tried this option in another place who has wireless network and I can watch.
    Do you have any idea to do these setting , I dont have any problem when Ipad has 6.1.3 IOS,
    need help
    thanks

    Thanks
    I will and share the result.

  • Need help with threads?.. please check my approach!!

    Hello frnds,
    I am trying to write a program.. who monitors my external tool.. please check my way of doing it.. as whenever i write programs having thread.. i end up goosy.. :(
    first let me tell.. what I want from program.. I have to start an external tool.. on separate thread.. (as it takes some time).. then it takes some arguments(3 arguments).. from file.. so i read the file.. and have to run tool.. continously.. until there are arguments left.. in file.. or.. user has stopped it by pressing STOP button..
    I have to put a marker in file too.. so that.. if program started again.. file is read from marker postion.. !!
    Hope I make clear.. what am trying to do!!
    My approach is like..
    1. Have two buttons.. START and STOP on Frame..
    START--> pressed
    2. check marker("$" sign.. placed in beginning of file during start).. on file..
         read File from marker.. got 3 arg.. pass it to tool.. and run it.. (on separate thread).. put marker.. (for next reading)
         Step 2.. continously..
    3. STOP--> pressed
         until last thread.. stops.. keep running the tool.. and when last thread stops.. stop reading any more arguments..
    Question is:
    1. Should i read file again and again.. ?.. or read it once after "$" sign.. store data in array.. and once stopped pressed.. read file again.. and put marker ("$" sign) at last read line..
    2. how should i know when my thread has stopped.. so I start tool again??.. am totally confused.. !!
    please modify my approach.. if u find anything odd..
    Thanks a lot in advance
    gervini

    Hello,
    I have no experience with threads or with having more than run "program" in a single java file. All my java files have the same structure. This master.java looks something like this:
    ---master.java---------------------------------------------------
    import java.sql.*;
    import...
    public class Master {
    public static void main(String args []) throws SQLException, IOException {
    //create connection pool here
    while (true) { // start loop here (each loop takes about five minutes)
    // set values of variables
    // select a slave process to run (from a list of slave programs)
    execute selected slave program
    // check for loop exit value
    } // end while loop
    System.out.println("Program Complete");
    } catch (Exception e) {
    System.out.println("Error: " + e);
    } finally {
    if (rSet1 != null)
    try { rSet1.close(); } catch( SQLException ignore ) { /* ignored */ }
    connection.close();
    -------end master.java--------------------------------------------------------
    This master.java program will run continuously for days or weeks, each time through the loop starting another slave process which runs for five minutes to up to an hour, which means there may be ten to twenty of these slave processes running simultaneously.
    I believe threads is the best way to do this, but I don't know where to locate these slave programs: either inside the master.java program or separate slave.java files? I will need help with either method.
    Your help is greatly appreciated. Thank you.
    Logan

  • Need Help about my email folder on my curve 8520

    Need help
    How to use the same folder email on my blackberry?
    When I change my mobile network and register again my bb and setup email again with my old email, my bb will make a new folder to store my email.
    How can I change my bb setting still using my old email folder?
    Thank you
    Solved!
    Go to Solution.

    Yep, different moble providers, different BIS BlackBerry Internet Service accounts.
    I dont understand the problem. Look at your main Messages folder. Press the Menu key > Inbox Settings, can you select there which email accounts go to the main Messages folder?
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Need help about career life

    Hi All,
    Em..i just need some advice about choosing correct career path.I graduated with a first class in IT with business information science in 2009. In 2009 after looking for jobs for few months i took a manager post in a petrol station which i never wanted.(Due to the credit crunch & the Family financial reasons) .Then unfortunately i had to stay out of work for 18months due to a serious spinal code operation i had to face.now in 2011 July im fit & ready to start my life again. but im lost where to start/ which career path to choose. (i've still got the job at the petrol station as the manager)
    ive liked data base management subject when i was in the University so, Ive been reading OCA-051 & interested on OCA qualification I just want to know what are the possible jobs i can apply if i get the certification? Basically what should i do to get any IT related job? :( ( i dont like programming)..
    Please be kind to reply.
    ps:i live in the Uk.
    Thanks.

    872882 wrote:
    Hi All,
    Em..i just need some advice about choosing correct career path.I graduated with a first class in IT with business information science in 2009. In 2009 after looking for jobs for few months i took a manager post in a petrol station which i never wanted.(Due to the credit crunch & the Family financial reasons) .Then unfortunately i had to stay out of work for 18months due to a serious spinal code operation i had to face.now in 2011 July im fit & ready to start my life again. but im lost where to start/ which career path to choose. (i've still got the job at the petrol station as the manager)
    ive liked data base management subject when i was in the University so, Ive been reading OCA-051 & interested on OCA qualification I just want to know what are the possible jobs i can apply if i get the certification? Basically what should i do to get any IT related job? :( ( i dont like programming)..
    Please be kind to reply.
    ps:i live in the Uk.
    Thanks.You'll sit on your bum and ruin your back again with most IT jobs. With your government shrinking, OCA qualification won't have much worth unless you personally know someone in the private sector that needs help. An operator job with your petrol company (assuming it's not just a mom 'n pop station) would probably require heavy lifting.
    IT is a good, solid, growing career path, but most of the work is still programming, and most ways up to better jobs go through that experience. You might be an exception if you have a way to join other skills with your IT education, such as business analysis or sales or web prettyfying. Perhaps the determinants are your personality and goals.
    I know, it's tough, but if you are honest with yourself and check out some of the "what color is my parachute" kinds of career advice books, you can find a happy medium. There actually are some benefits in starting a career during economically troubled times, but you only see that in retrospect. You have to decide on goals, pursue them vigorously, and reevaluate when it doesn't work for you.

  • Need Help About AC or battery or pc :(

    Hello!
    i am kinda new to the forum,i have GT70 2pe dominator pro laptop(bought from ibuypower) When i play demanding games,my ac unplugs itself from the laptop i dont know what to do ,i updated ec,bios,did the ec reset,battery calibration(from msi support page), but i did these long time ago i dont know if this started then or the problem was already on pc when i bought it,i didnt test playing demanding games before i did those things
    I tried playing w/o battery sometimes when the game loads laptop shuts down
    So i really need help..? 

    i think i have the correct model,well if it is going to fail can i use it until i buy a new one 2 weeks later?,i mean is this going to do harm to my computer until i get a new one?
    Thanks for the help  (sorry about the full sized picture)

  • Need help about how to capture the name of an object before inserting.

    Hi everybody,
    how i can capture the name of an object before it inserts in a table.
    i will use a pre-insert trigger to do this, but i don't know how to specify the name of the object that's inserting.
    any help about this issue will be appreciated.

    Mentioning objects you mean: You have a procedure which inserts data into some table and this procedure needs to know the name of the caller (another procedure or ...)
    Can this be of some help http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:382218730166 ?
    Regards
    Etbin

  • Need help about button

    Hi everybody!
    I'm from Italy, so I need help regarding button
    I create an animation, I put a button to replay the movie by this code:
    on (release) {
    gotoAndPlay(1);
    but in AS3 doesn't work. Can you help me pls?
    Another problem...I need a very simple preloader that display only percentage, stop.
    Anybody knows a template or tutorial about this?
    Thx in advance!

    What do you mean by scene2?. You can only preload external content like a picture, another swf, etc...a much simpler example:
    var myLoader:Loader = new Loader();
    addChildAt(myLoader,0)
    myLoader.load(new URLRequest("http://www.snowman-jim.org/science/images/north-pole-sun-moon.jpg"))
    myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loading)
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishLoading)
    function loading(e:ProgressEvent):void{
        info_txt.text="Loading.."Math.floor(e.currentTarget.bytesLoaded/1024)" Kb";//e.currentTarget is referring to myLoader.contentLoaderInfo
    function finalizado(e:Event):void{
        info_txt.text="I'm done!";
    Just change myLoader.load(new URLRequest("http://www.snowman-jim.org/science/images/north-pole-sun-moon.jpg")) path for the relevant path to the file you want to preload.

Maybe you are looking for

  • How Do You Restart a Failing Load Plan

    If a Load Plan step fails, say because of some bad data or a bad join, I know how to correct the error and restart the failing step or the failing task in the Operator. How do you restart the failing Load Plan or any higher level step in the Operator

  • Very urgent..Formula count

    Hi All I have a Query got 4 RKFs(local) 2 Formula(ckfs),  the out put is like this, rkf1 rkf2  fkf1  fkf2 0    30      1     0 0     0       0     0 20   0      0     1 Result    1      1 i have created these 2 fks based on 2 rkfs when i try to count

  • Equivalent of "connect by " clause in SQL Server's T/SQL to get family tree branches

    Is there any equivalent command in SQL Server's T/SQL for the command :- select parent, offspring from table_family start by offspring='child1' connect by parent=PRIOR offspring

  • Darken a pdf file

    I downloaded a trial version of Elemenst 7 to see if I can darken a pdf file.when open a pdf file I get an error message saying it is not a Adobe Photo.. PDF image file. how can I darken a pdf file?

  • Printing in Chinese for photobook

    Hello All, I want to print the photobook with introduction in Chinese. Did anyone in the forum print the album by Apple in Chinese before? What is your experience? Many Thanks, Anthony iMac 2Gb intel duo core   Mac OS X (10.4.8)