Child thread stopping a parent thread

I have a java program which has to pick some list of records from table1 and iterate through the list and send a message to an external URL and after getting a response update the same table.
The issue here is I use HttpUrlconnection and open an InputStream from the connection to read the response message from the external URL.
This Java program hangs when getting the response from the external URL.(for some reason the external server is busy and does not send a response in time)
I need to find out some way to get this process out, from waiting for the response from the external URL.
I have used HttpUrlconnection.disconnect and Thread.interrupt ... both do not "get the process out of wait for response".
Do any of you have a solution to this issue ?
Thanks.

sukumar.sudha wrote:
Java 1.4 doesnot have setConnectTimeout and setReadTimeout.So I prefer using setSoTimeout.I think it would be easier to start a thread that does the HttpURLConnection stuff and
when done notifies you (Object.notify()). After you start the thread, you wait(timeout).
When this wait returns, you can check if the other thread is done or not.
If yes, all fine. If not, you have your continuation without waiting for completion of the
HttpURLConnection stuff. The HttpURLConnection will still be attempting to extract the data,
but should you really care? You achieved the goal of having your main thread move forward.
Why I think this is better? Simply HttpURLConnection gives you lots of free stuff that you
would have to implement yourself with sockets.

Similar Messages

  • How to kill parent and child thread in sequnece

    Hello freinds,
    I have one class FirstClass which creates one thread Pserver and Pserver creates three threads then how to kill parent Pserver and child threads.........

    define a method that requests that the parent thread terminate itself, and within the code called when the thread is shutting itself down, have it do something similar to its child threads: call methods that request they shutdown themselves.
    One common way to do this is to interrupt the thread.

  • Can a parent thread kill a child thread?

    I'm writing a multi-threaded application in which it is possible for one of the threads to go into an infinite loop. Is there any way for a parent thread to actually kill the child thread that has gone into the infinite loop? Of course the parent thread won't actually be able to discern whether or not the child thread is in an infinite loop. I would specify some time out value, and when it has been exceeded, then I would want to kill the child thread. Is this possible without setting any sort of flag that the child would read, because once it gets stuck inside an infinite loop, there will be no way to read the flag.

    Here's an example of a program that I wrote to simply ping a server. It works somewhat backwards from what you were looking for (the child interrupts the parent) but should provide some clue:
    import java.net.*;
    import java.io.*;
    import java.util.Date;
    public class ServerPing extends Thread {
      String [] args;
      public static void main(String[] args) throws Exception {
        ServerPing sp = new ServerPing(args);
        sp.start();
      ServerPing(String [] args) {
        this.args = args;
      public void run() {
        Pinger pinger = new Pinger(this);
        pinger.start();
        try {
          sleep(30000);
        catch (InterruptedException x) {
          System.exit(0); // this is ok. It means the pinger interrupted.
        System.out.println("TIMEOUT");
        System.exit(1);
    class Pinger extends Thread {
      Thread p = null;
      Pinger (Thread p) {
        this.p = p;
      public void run() {
        try {
          URL simpleURL = new URL("http://localhost:7001/ping.jsp");
          BufferedReader in = new BufferedReader(new InputStreamReader(simpleURL.openStream()));
          String inputLine;
          while ((inputLine = in.readLine()) != null)
          System.out.println(inputLine);
          in.close();
          p.interrupt();   // <<-- interrupt the parent
        catch (Exception x) {
          x.printStackTrace();
    }

  • Java Thread - difficulty while passing value from parent to child thread

    Hi All,
    I am calling a java program from a unix script .
    My oblectives are
    1)to pass value from scripts to main java class
    2)main class should create a child thread and pass data to child and should return control back to script
    3)child thread should run independtly of parent
    The calling unix script is part of process and hence should return control back to its calling script immediately.
    Findings
    1)Without passing data thru setter getter /constructor method to child thread my objectives are met
    2)When I pass the data from parent thread to child thread calling unix scripts wait till child thread finishesh its working
    call.scr
    java Main <list of Arguments>
    Main.java
    public class Main
                 public static void main(String args[]) throws Exception
                 String data2="Z";
                 String data1=null;
                 for(int i=0;i<args.length;i++)
                      data2=data2+","+args;
    data1=data2;
    Child cu=new Child();
    cu.setData(data1);
    data2=null;
    data1=null;
    cu.start();
    Child.javaclass Child extends Thread
    public String data;
    void setData(String data)
    this.data=data;
    public void run()
    ----------> processing on data
    I think due to passing of data from parent thread to child thread (Inter thread data communication/Inter process communication)
      the threads are not working as desired.
    Plz anybody can suggest something.....
    Thanx.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    aschin,
    You seem to be confusing Java Threads with Operating System Processes.
    If you want you're java program to run in the unix background then you'll need to run it in the unix background. Java (being o/s agnostistic) doesn't provide process manipulation functionality (which would include the ability to throw itself into the background, as a C program can) in the standard API, and it's hard to imagine any third party producing anything as low level as a process controler... so yeah, just start the java program in the background... and you'll need to workout some interprocess communication protocol... named pipes have worked well for me in the past, as they doesn't suffer from the quit same performance issues as real disk files.
    Good luck. Keith.

  • Why can't I interrupt the main thread from a child thread with this code?

    I am trying to find an elegant way for a child thread (spawned from a main thread) to stop what its doing and tell the main thread something went wrong. I thought that if I invoke mainThread.interrupt() from the child thread by giving the child thread a reference to the main thread, that would do the trick. But it doesn't work all the time. I want to know why. Here's my code below:
    The main class:
    * IF YOU RUN THIS OFTEN ENOUGH, YOU'LL NOTICE THE "Child Please!" MESSAGE NOT SHOW AT SOME POINT. WHY?
    public class InterruptingParentFromChildThread
         public static void main( String args[] )
              Thread child = new Thread( new ChildThread( Thread.currentThread() ) );
              child.start();
              try
                   child.join();
              catch( InterruptedException e )
    // THE LINE BELOW DOESN'T GET PRINTED EVERY SINGLE TIME ALTHOUGH IT WORKS MOST TIMES, WHY?
                   System.out.println( "Child please!" );
              System.out.println( "ALL DONE!" );
    The class for the child thread:
    public class ChildThread implements Runnable
         Thread mParent;
         public ChildThread( Thread inParent )
              mParent = inParent;
         public void run()
              System.out.println( "In child thread." );
              System.out.println( "Let's interrupt the parent thread now." );
              // THE COMMENTED OUT LINE BELOW, IF UNCOMMENTED, DOESN'T INVOKE InterruptedException THAT CAN BE CAUGHT IN THE MAIN CLASS' CATCH BLOCK, WHY?
              //Thread.currentThread().interrupt();
              // THIS LINE BELOW ONLY WORKS SOMETIMES, WHY?
              mParent.interrupt();
    }

    EJP wrote:
    I'm not convinced about that. The wording in join() suggests that, but the wording in interrupt() definitely does not.Thread.join() doesn't really provide much in the way of details, but Object.wait() does:
    "throws InterruptedException - if any thread interrupted the current thread +before+ or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown."
    every jdk method i've used which throws InterruptedException will always throw if entered while a thread is currently interrupted. admitted, i rarely use Thread.join(), so it's possible that method could be different. however, that makes the thread interruption far less useful if it's required to hit the thread while it's already paused.
    a simple test with Thread.sleep() confirms my expected behavior (sleep will throw):
    Thread.currentThread().interrupt();
    Thread.sleep(1000L);

  • Waiting the main thread till all child thread has completed

    I am in the process of developing a batch application in Java 5.0 which extensively uses the java.util.concurrency API. Here is a small description of what the batch process will do,
    1. Retrieve values from DB and populate a blocking queue in main thread.
    2. Instantiate a Threadpool by calling, Executors.newFixedThreadPool(2)
    3. Invoking the following block of code from the main thread,
    while(!iBlockingQueue.isEmpty()) {
        AbstractProcessor lProcessor = new  DefaultProcessor((BusinessObject)iBlockingQueue.remove());
        iThreadPool.execute(lProcessor);
    }DefaultProcessor is a class that extends Thread.
    4. Invoking the following block of code from the main thread,
    iThreadPool.shutdown();
    try {
         iThreadPool.awaitTermination(30, TimeUnit.SECONDS);
         } catch (InterruptedException interruptedException) {
              iLogger.debug("Error in await termination...", interruptedException);
    Since, this is the first time I am using the java.util.concurrency API, I want to know whether this is the right way to wait for all the child threads to complete before executing further statements in the main (parent) thread. Or do I necessariliy have to call join() to ensure that the main thread waits for all the child threads to finish which can only happen when the queue is empty.
    Please note here that as per the requirements of the application the blocking queue is filled only once at the very beginning.
    I will appreciate any inputs on this.
    Thanks.

    looks like you would be waiting on a queue twice, once in the loop and again, under the hood, in the threadpool's execute()
    the threadpool's internal queue is all that is needed
    if your iBlockingQueue is also the threadpool's internal queue, you might have a problem when you remove() the BusinessObject
    by making DefaultProcessor extend Thread you are, in effect, implementing your own threadpool without the pooling
    DefaultProcessor need only implement Runnable, it will be wrapped in a thread within the pool and start() called
    to implement a clean shutdown, I suggest writing DefaultProcessor.run() as an infinite loop around the blocking queue poll(timeout) and a stop flag that is checked before going back to poll
    class DefaultProcessor implements Runnable {
      private BlockingQueue myQ;
      private boolean myStopFlag;
      DefaultProcessor( BlockingQueue bq ) { myQ = bq; }
      public void run() {
        BusinessObject bo = null;
        while( !myStopFlag && (bo=myQ.poll( 10, SECONDS )) ) {
          // business code here
      public void stop() { myStopFlag = true; }
    } Now, after iThreadPool.shutdown(), either call stop() on all DefaultProcessors (or alternatively send "poison" messages to the queue), and give yourself enough time to allow processing to finish.

  • Running bat file in Child Thread

    Hi
    Please first of all i will tell you my application flow.
    I have an application you can say Parent Process/application , In execution of this Process or thread my application start/run batch file before dying using "exec() funtion" .In batch i have some scripts.and after initiating batch command my application main process ends up.
    Now problem is
    I am not sure that child process or Batch script which main program called is alive when my main application closed or its running?
    i want to see its output on console?
    Is it possible that Parent Thread ends up and child is still running , how can i achieve this .
    OR is it possible that i create seprate thread to start batch and my main thread ends. and i will show batch file output on console.

    I'm having a hard time understanding what you're
    saying, so here are a few general things that may be
    relevant:Sorry for that , well you are very much near which i want.But Thanks
    * Child threads can keep running after the thread
    that spawned them dies. You don't need to do anything
    special here.
    * The VM will exit when there are no more non-daemon
    threads running. So if you make all threads other
    than your main thread daemons, then when main ends,
    the rest of the threads will die and the VM will
    exit. See Thread.setDaemon.Here in above two point i have confusion.that by VM you mean Parent process,
    VM is parent process of all java programs that we run.please clarify this
    Lets say VM is parent process than your first statement is no valid as in first you say that parent die it will not effect child threads.
    well i have test this case with my program i write a program like
    public class ThreadTest
         public static void main(String [] arg)
              Work work=new Work(1000);
              System.out.println("Main Thread Started"+work.isDaemon());
              work.setDaemon(false);
              work.start();
              System.out.println("Main Thread stopped");
    class Work extends Thread
         int count=0;
         public Work(int cou)
              super("Workere");
              count=cou;
         public void run()
              while(count-->0)
                   System.err.println("Worker Thread is running................");
    }Now bydefault work thread is deamon,when all work thread steps executed program finished, tell me here as its concurent execution,
    main is alive or die when it execute its all statements or it waits for work thread which it spawned.
    Secondly when i change deamon to true, when main statements finished it also stoped work thread.mean work thread just print some messages.
    Actually what i want is that, when my main progam ends up, before ending it spawned new thread which start batch script and i want to see its output on seprate screen just like when we run IE with exec it starts IE window.
    Hope fully this time its clear

  • Initialize QTMovie in a child thread by passing Movie object.

    I'm working on an Qt (Qt framework) application in which I'm making use of a .mm file to call MAC specific functions.
    I need to initialize QTMovie in a child thread by passing Movie object.
    [QTMovie movieWithQuickTimeMovie:movie disposeWhenDone:TRUE error:nil]
    It appears like I have to initialize QTMovie in main thread. I came across performSelectorOnMainThread which might be of some help. Could anyone please show me the right usage of the same?
    I need to call a method using performSelectorOnMainThread by passing the Movie object to it and which returns the initialized QTMovie object.
    Thanks in advance.

    Ah, you seem to be on to something, there. The main thread gives
    sun.misc.Launcher$AppClassLoader@111f71
    while the child thread gives null. The same occurs whether the experiment is in
    the same JVM instance or not.
    So presumably this means I need to get the context loader from the main thread
    and set it in the child thread manually!?
    - Angus.
    Patrick Linskey wrote:
    Angus Monro <[email protected]> writes:
    Okay.... I'm not really sure what you're asking for. What I've done is
    printed the ClassLoader object as given by
    com.solarmetric.util.app.Prefs.class.getClassLoader(), along with its
    parent recursively up the tree of loaders. This gave:
    sun.misc.Launcher$AppClassLoader@111f71
    sun.misc.Launcher$ExtClassLoader@256a7c
    This result was exactly the same irrespective of whether I did it from the
    main thread or the child thread. But the exception still happens only the
    child thread.Sorry, I should have been more clear. Can you print out the current
    thread's context's classloader?
    System.out.println (Thread.currentThread ().getContextClassLoader ());
    Also, what happens if you run the test in the main thread and then in
    the child thread, all in the same JVM?
    -Patrick
    - Angus.
    Patrick Linskey [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • Exceptions in child thread

    Hello,
    I am writing a few classes that i plan on reusing a lot. The classes create
    child threads that do ... work. If a exception is cought in one of the child threads
    I want to send it up to the caller. I can't declare the run() method of a thread to throw
    an exception ... so could someone suggest a nice clean way to get the cought exception back to the caller.
    Thanks,
    jd

    To answer that question, you need to think about what the "caller" (the parent thread) is doing while the child thread is executing.
    Is it waiting in a join() call?
    Is it doing its own processing?
    What do you expect it to do when a child thread throws an exception?
    (The answer to the bolded questions may drive how you report the exception back to the parent thread.)
    With a typical single-threaded chain of calls, when an exception is encountered, there is a well defined stack back to the main() method--main called foo which called bar which called baz, etc. In a multithreaded context, the parent thread could potentially be executing any of its instructions when the exception occurs. Remember, the parent thread and child thread are executing independently of each other.

  • Closing all child threads when closing the stage

    I have multiple instances of child threads which are started and should continue to execute in till the applications exits.
    I have classes which extends Task and I create the threads as
    new Thread(object of the class).start();
    when it comes to interrupting/stoping (dont know which one is correct, please let me know) the threads which should be done inside
    primaryStage.onCloseOperation(){}
    here i want to end all child threads but since my threads are spreaded across different classes, my not having a clear picture how to achieve this.
    I know there is some designing problem, in my application, when it comes to threads, but I am not able to figure out how to resolve out.

    Use thread.setDaemon(true) Thread (Java Platform SE 7 )
    I suggest to use the Executor Framework and a ThreadFactory, to only need to create a daemon thread once.
    Something like this:
    Executor executor = Executors.newCachedThreadPool(new ThreadFactory() {
                @Override
                public Thread newThread(Runnable r) {
                    Thread thread = new Thread(r);
                    thread.setDaemon(true);
                    return thread;
    And then use it like this:
    executor.execute(yourTaskOrRunnable);
    When there are only daemon threads running, the JVM will halt and also stop all daemon threads.

  • TIme taken by Child threads to execute

    Hi
    I have a small query related to multithreading. I have a main thread launching a few Child threads. Now I want to check how much time all the 10000 child threads are taking to execute. I cannot write a System.currentTimeMillis(); before a main thread exits because I want the Child threads to keep executing even after the Main thread exits because I do not know how much time the child threads will take. I have made the child threads as non-deamon
    class ChildThread implements Runnable {
         Thread t;
         int i;
         ChildThread(int i) {
              t = new Thread(this, "SMS Thread");
              this.i = i;
              t.setDaemon(false);
              t.start();
         public void run() {
              try {
                   System.out.println(i);
              } catch (Exception smsex) {
                   System.out.println("Exception occured while sending message :"
                             + smsex.getMessage());
                   smsex.printStackTrace();
    public class MainThread {
         public static void main(String args[]) {
              long start = System.currentTimeMillis();
              ChildThread thread = null;
              try {
                   for (int i = 10000; i > 0; i--) {
                        thread = new ChildThread(i); // create a new thread
              } catch (Exception e) {
                   System.out.println("Main thread interrupted.");
              long end = System.currentTimeMillis();
              System.out.println("Main thread exiting. Took " + (end - start)
                        + " ms.");
    }

    This is a sample i have assumed.. dont have the complete code.
    I will just explain this
    Create an executor service object in a class called ThreadDispatcher.
    And create your chileThread as given below
    class ChildThread implements Runnable {
         ChildThread() {                    
         public void run() {
              try {
                   System.out.println(i);
              } catch (Exception smsex) {
                   System.out.println("Exception occured while sending message :"
                             + smsex.getMessage());
                   smsex.printStackTrace();
    }And the ThreadDispatcher class as below -This is just to beautify the code :)
    public class ThreadUtil {
    private static ExecutorService exec = Executors.newFixedThreadPool(some_value);
    public static List<Future> executionResults = new ArrayList<Future>();
    }And finaly come to the main Thread class
    public class MainThread {
         public static void main(String args[]) {
              ChildThread thread = null;
              try {
                             long start = System.currentTimeMillis();
                   for (int i = 10000; i > 0; i--) {
                        thread = new ChildThread(i); // create a new thread
                                    ThreadDispatcher.executionResults.add(ThreadDispatcher.exec.submit(thread));
              } catch (Exception e) {
                   System.out.println("Main thread interrupted.");
                    //Here place the while loop to check each thread status
                     while (ThreadDispatcher.executionResults.size() > 0) {
                   try {
                        Future task = ThreadDispatcher.executionResults.get(0);
                        task.get();//Wait until the thread finishes execution
                                    ThreadDispatcher.executionResults.remove(task);
                   } catch (InterruptedException e) {
                        e.printStackTrace();
                   } catch (ExecutionException e) {
                        e.printStackTrace();
              long end = System.currentTimeMillis(); //This time will probably be the end time.
              System.out.println("Main thread exiting. Took " + (end - start)
                        + " ms.");
    }Hope this will be helpful...

  • Running child thread till completion even after main thread is terminated

    I am running some task in background using Task and Service Api's. When the main application spawns few threads, can the main thread be terminated without terminating the child thread. Is it possible. Thanks.

    Read up on daemon threads.
    multithreading - What is Daemon thread in java - Stack Overflow
    Also read the
      Application Lifecycle section in the javadoc.

  • Find child record of a parent record

    Hi,
    I need to find the child recond of a parent party and if that child also have some
    child then I need to find again and this process will go untill no child record
    found(child is null)
    I am trying to do it by the help of hierarchical query.
    can anyone please help and tell me how can I do that and how can I handle if a parent have multiple childs.
    Mohan

    It is always helpful to provide the following:
    1. Oracle version (SELECT * FROM V$VERSION)
    2. Sample data in the form of CREATE / INSERT statements.
    3. Expected output
    4. Explanation of expected output (A.K.A. "business logic")
    5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.
    Also see the third post in this thread:
    {thread:id=2174552}
    This would probably be better suited in the {forum:id=75} forum.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Transfer Focus From a Child Dialog To its Parent Frame

    Hi
    I m working on a Multimedia Desktop Application. I have done alomst 90% of work. Here I have a problem to transfer focus from a Child Dialog to Parent Frame. Remember the whole applicatio does not use Mouse every thing is handled on key events. So I required to transefer the focus from a Child Dialog to its Parent Frame from key board. I also cant use ALT+TAB because
    1- Child is a dialog
    2- This is a Multimedia Application which will be deployed For TV production and can't allow any Computer
    Components to be viewable.
    So I want only key press to transfer the focus between Child and The Parent.
    Thanks.
    Khurram

    First u tell me what do u do on the forumI answer questions - when I know the answer.
    I give advice on how to use the forums efficiently so you get the best chance to have your question answered and you don't waste other peoples time.
    And the post-URL you mentioned, was mistakenly submitted two times.Then respond to your own thread saying you posted it twice by mistake.
    any ways I did never see any article posted by you, nor the solutions on the other's posts by you. you just made comments on others posts.which only goes to prove that you never bother to search the fourm before you post a question.
    and please let others try to review on my problem.others can still reply

  • Creating AWT child dialog within a parent hangs in 1.7 but works with 1.6

    Hi,
    We are making use of Java AWT packages. In which we are creating an child dialog within a parent window and it hangs, meaning none of the buttons on the child window works, even the close is not happening (parent, child and console all hangs, need to kill the applet from the task manager). No error/exception is seen in the Console. No deadlocks noticed in the thread dumps.
    This is seen only with JRE1.7 (update 10,11,13,15) version. But the same code is working fine with JRE 1.6 version.
    We also have same codebase of next release, where the code is changed to Swings and that seems to work with JRE1.7.
    Can somebody suggest me what might be causing it to fail with JRE_1.7 at the earliest as this a critical issue.
    Thanks in advance!

    We have a tuxedo service which needs to communicate with a POS device by socket. The parent process provides the tuxedo service. The child process provides the connection management for the device. Unnamed pipe is used for communication between the parent and the child. In the child process, there is no code related to tuxedo. The benefit of that design is the tuxedo server does not need to wait for connection from the device when boots up, and the tuxedo service does not need to wait for connection from the device when the service is called.
    The tuxedo server was developed 10 years ago, and worked fine till we upgraded tuxedo from 10 to 12 recently. That means it worked for 10 years, and it worked in tuxedo 6.5, tuxedo 10. But in tuxedo 12, tmboot does not return for this tuxedo server. We have to press CTRL-C and yes to cancel. After cancel, the tuxedo service seems working fine.

  • How to add an item object as a child for a specified parent node in AdvancedDataGrid in Flex?

    Hi all,
              This is the code, to add a object as a child into a specified parent node in AdvancedDataGrid in flex.
    <?xml version="1.0" encoding="utf-8"?><mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onCreationComplete()" width="100%" height="100%">
    <mx:Script><![CDATA[
    importmx.controls.Alert; 
    importmx.collections.IHierarchicalCollectionViewCursor; 
    importmx.collections.IHierarchicalCollectionView;  
    importmx.collections.ArrayCollection; [
    Bindable]private var objectAC:ArrayCollection = newArrayCollection(); 
    //This method is used to construct the ArrayCollection 'flatData' 
    private function onCreationComplete():void{
    var objOne:Object = newObject(); objOne.name =
    "Rani"; objOne.city =
    "Chennai";objectAC.addItem(objOne);
    var objTwo:Object = newObject(); objTwo.name =
    "Rani"objTwo.city =
    "Bangalore";objectAC.addItem(objTwo);
    var objThree:Object = newObject(); objThree.name =
    "Raja"; objThree.city =
    "Mumbai";objectAC.addItem(objThree);
    //This method is used to add one object as a child item for the parent node 'Rani' 
    private function addChildItem():void{
    var dp:IHierarchicalCollectionView = groupedADG.dataProvider asIHierarchicalCollectionView;  
    varcurent:IHierarchicalCollectionViewCursor = groupedADG.dataProvider.createCursor();  
    var dummyParentNode:Object = {name:"Rani", city:"New Delhi"};  
    var obj:Object = null; 
    while(curent.current){
    // To get the current node objectobj = curent.current;
    // Add Child item, when depth = 1 and Node name should be "Rani" 
    if (curent.currentDepth == 1 && obj["GroupLabel"] == "Rani"){
    dp.addChild(curent.current, dummyParentNode);
    curent.moveNext();
    groupedADG.dataProvider = dp;
    groupedADG.validateNow();
    groupedADG.dataProvider.refresh();
    ]]>
    </mx:Script> 
    <mx:AdvancedDataGrid id="groupedADG" x="10" y="15" designViewDataType="tree" defaultLeafIcon="{null}" sortExpertMode="true" width="305" > 
    <mx:dataProvider> 
    <mx:GroupingCollection id="gc" source="{objectAC}"> 
    <mx:grouping> 
    <mx:Grouping> 
    <mx:GroupingField name="name"/> 
    </mx:Grouping> 
    </mx:grouping> 
    </mx:GroupingCollection> 
    </mx:dataProvider> 
    <mx:columns> 
    <mx:AdvancedDataGridColumn headerText="Name" dataField="name"/> 
    <mx:AdvancedDataGridColumn headerText="City" dataField="city"/> 
    </mx:columns> 
    </mx:AdvancedDataGrid> 
    <mx:Button x="10" y="179" label="Open the folder 'Rani'. Then Click this Button" width="305" click="addChildItem()" /> 
    </mx:Application> 

    Hi,
    It's not possible to 'append' a StringItem or a TextField (or any other lcdui.Item object) to a Canvas or GameCanvas. You can only draw lines, draw images, draw text, etc etc, on a Canvas screen. So, you can only 'simulate' the look and feel of a TextField (on a Canvas) by painting it and adding source code for command handling (like key presses). However, this will be quite some work!!
    lcdui.Item objects can only be 'appended' to a Form-like Displayable.
    Cheers for now,
    Jasper

Maybe you are looking for