Dynamic Thread Creation

To anyone that can help,
I am very new to JAVA, and have been given the job of creating an application that allows a user to dynamically create a number of process which perform the same task (its a load-testing tool). I thought that using threads would be the best approach, however, I am not sure how to instantiate them dynamically. The two ways I known are :
1.
NewThread one = new NewThread(arguements);
one.start();
2. new NewThread(arguements).start();
The second one would probably work via. user input. The problem is that since I haven't named the object (like in case 1) I can't access its methods (i.e. join()). I guess this question could be extend to consider creating any object dynamically, so any help would be very much appreciated.
Thanks

I'm not entirely sure of what your question is... but I'll try to guess at it.
The only difference between the two approaches is whether your program will keep a handle/reference to the class that extends Thread or implements runnable.
NewThread one = new NewThread(arguements);
one.start(); In the first case you can just take your "one" variable and throw it into a container, if you want to reference it and others like it.
2. new NewThread(arguements).start(); In this case, you don't have a variable that references the thread that you just started.
Can you provide more information on what you want to do with the Thread process once it has started?
Thanks,
Tim
To anyone that can help,
I am very new to JAVA, and have been
and have been given the job of creating an application
that allows a user to dynamically create a number of
process which perform the same task (its a
load-testing tool). I thought that using threads would
be the best approach, however, I am not sure how to
instantiate them dynamically. The two ways I known are
1.
NewThread one = new NewThread(arguements);
one.start();
2. new NewThread(arguements).start();
The second one would probably work via. user input.
The problem is that since I haven't named the object
(like in case 1) I can't access its methods (i.e.
join()). I guess this question could be extend to
consider creating any object dynamically, so any help
would be very much appreciated.
Thanks

Similar Messages

  • Dynamic thread creation in Forums

    Dear All,
    Is it possible to create/start a new thread in Forums dynamically, based on some eventing ?
    Like, I have an jsp containing a check-box and a text-box, if this jsp is submitted with the check-box checked then a new thread should be automatically created in Forums section of the portal with the Subject as mentioned in text-box, without any manual intervention. Can it be achieved ?
    Regards,
    SM

    Again we have the same problem here. When you post it redirects you to
    /forums/thread.jspa?threadID=.....
    and since you don't have /irj in the url it automatically redirects you to :
    /irj/portal/forums?ForumsTarget=thread.jspa?threadID=...
    You have to create an "Forum Iview" with quick link "forums" as desribed in forum installation guide.
    1. In the portal, choose Content Administration -> Portal Content.
    2. In the Portal Content Studio locate the target folder for your new iView.
    3. In the context menu of the target folder, choose New -> iView.
    4. Select the custom iView template for forums.
    5. Enter the required values and then choose Finish.
    6. Select Open the object for editing.
    7. In the property editor for each of the forums iViews, perform the following steps:
    1. Select the property category Forums Configuration.
    2. For the property View on Forums, select Forums.
    3. Select the property category Navigation.
    4. For the property Quick link, enter forums.

  • RE: dynamic widget creation

    This is a good tech note about this on the Forte website.
    -----Original Message-----
    From: Matthew Middleton [SMTP:[email protected]]
    Sent: Friday, 25 June 1999 11:11
    To: [email protected]
    Subject: dynamic widget creation
    I have done a few windows with dynamic widget creation. Sometimes it
    seems I have to have done self.Open before, to get things to appear
    properly, and sometimes not.
    What I would like is a summation of the issues involved here so I can
    write such code without resorting to trial and error.
    with advance appreciation,
    Matthew
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive
    <URL:http://pinehurst.sageit.com/listarchive/>-
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    Tech Note 5156, which I have attached for your information.
    -----Original Message-----
    From: Foster, Todd [SMTP:[email protected]]
    Sent: Saturday, 26 June 1999 1:27
    To: 'Jason de Cean'
    Subject: RE: dynamic widget creation
    ? What technote ?
    -----Original Message-----
    From: Jason de Cean [SMTP:[email protected]]
    Sent: Thursday, June 24, 1999 9:19 PM
    To: 'Matthew Middleton'
    Cc: 'Forte Users'
    Subject: RE: dynamic widget creation
    This is a good tech note about this on the Forte website.
    -----Original Message-----
    From: Matthew Middleton [SMTP:[email protected]]
    Sent: Friday, 25 June 1999 11:11
    To: [email protected]
    Subject: dynamic widget creation
    I have done a few windows with dynamic widget creation. Sometimes
    it
    seems I have to have done self.Open before, to get things toappear
    properly, and sometimes not.
    What I would like is a summation of the issues involved here so Ican
    write such code without resorting to trial and error.
    with advance appreciation,
    Matthew
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive
    <URL:http://pinehurst.sageit.com/listarchive/>-
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive<URL:http://pinehurst.sageit.com/listarchive/>

  • Dynamic Table Creation & Fill Up

    Hello,
    Can anyone please guide where I can find examples for dynamic table creation (programmaticaly), with dynamic number of columns and rows, used to place inside text components (or whatever) to fill them with data.
    All programmatic.
    Using JSF, ADF BC
    JDeveloper 10.1.3.1
    Thanks
    Message was edited by:
    RJundi

    Hi,
    Meybe this article helps: http://technology.amis.nl/blog/?p=2306
    Kuba

  • Regarding Thread Creation

    Hello,
    To create a thread in java there are two methods.
    (1) by extending from thread class.
    (2) by implementing runnable interface.
    implementing runnable interface is the preferred method to create a thread because we still have the option to extend from any other class.
    But does anybody know why java provides 2 methods for thread creation, why doesn't it provide only option 2 (i.e. by implementing runnable interface) when it is the preferred option.
    Regards,
    Sandy.

    Though Runnable interface is preferred to create threads in Java,most programmers extends Thread class.As jschell would say, 'I am rather certain' that the opposite is true.
    The reason behind of this is that you can have a clear logic of your code by using ThreadThat's not even true and it certainly isn't a reason to extend Thread rather than implement Runnable.
    most of the system programming written in java used Thread class instead of Runnable interface .If you have some evidence on the point please produce it. The consensus of opinion on these forums has been the other way round for many years.

  • Does Seeburger's SFTP adapter support dynamic filename creation

    Hi all,
    Does the SFTP adapter support dynamic filename creation.
    If yes, then do we have to use UDF's and are there any specific settings that have to be done in the SFTP communication channel.
    Please provide a blog which helps in the configuration process of the above case.
    thanks,
    younus

    Dynamic Creation of File using counter in Seeburger Variable:
    1. Configuration Needed in the Communication Channel:
    The process of dynamic creation of files can be done we have to select the following checkbox in the receiver channel:
    Dynamic Attribute in receiver Channel:
    Import the following modules:
    Localejbs/Seeburger/solution/sftp
    Localejbs/Seeburger/AttribMapper
    Localejbs/ModuleProcessorExitBean
    Enter  the desired file naming convention:
    Use the Parameter GetCounter("ID") to the place where the counter is expected to come.
    2. Configuration Needed in the SeeBurger Workbench:
    If the J2EE server is listening on a port different from 50000 (which is the standard for the SAP client 000), the port number must be configured:
    Login into the seeburger workbench using the URL
    http://<localhost>:<port number>/seeburger/index.html
    Select Property Store.
    Create or edit the following property:
    Parameter
    Value
    Namespace
    http://seeburger.com/xi/SeeFunctions
    Key
    provider.servlet.server
    Value
    http://localhost:50000/ (where the port number 50000 must be set
    accordingly to the J2EE server configuration).
    Note: The configured value (server URL) has to end with a slash (/). Otherwise,
    SeeFunctions will not work correctly.
    If we need to start the counter from any specific value , it can be configured in the SeeBurger workbench, this value can be maintained in Mapping Variables :

  • Does UCM support dynamic page creation on contributor mode.?

    Hi All,
    Does UCM support dynamic page creation on contributor mode.
    We want to create new pages and link it into the existing pages
    is that possible?
    Thanks
    ~Hari

    You can create new secondary pages in contributor mode - you would normally do this via a dynamic list fragment though technically you could also achieve it by switching region content and creating new data files. You can then use the linz wizard to link between pages.
    If you are talking about creating new primary pages and sections in your site then you would need to use something like Site Studio Manager fragment.
    Tim

  • Thread creation error: Not enough storage is available to process this command

    Two user in my company have this problem, I have already used the solution on the community but would come back after 2 to 3 weeks. They all have the message "Thread creation error: Not enough storage is available to process this command". I tried increase the virtual memory to 4Gb, update one client to the latest, reset IRPStackSize, delete temp folder.  one client is 7.5.XX with windows 7 and another is 6.20.0.104 with Windows XP,My machine is also 6.20 with windows 7 but I dont have this problem.   

    Version previous to 7.6 worked fine. After update I have got this message and mostly of Skype GUI turns black or vanishes. No possibility of making more than one call before crash, It is amazing that a thread started about two weeks ago has no technical answer, at least. What do I do with my credits and my appointments? Throw them away?

  • Thread creation error: Not enough storage space

    Hi,
      Recently (the past week or so), my desktop client for Skype has been crashing regularly. This is accompanied by large (over 1.2GB) amounts of memory usage. At semi-regular intervals (say every few hours), Skype will post an error with the text "Thread creation error: Not enough storage space..."
    I am using the latest build of Skype. I am not performing any Skype logging. This error is clearly an ongoing issue which has not been addressed, as prior threads have discussed this as well.

    Errors like this have been addressed and continue to be addressed.  Being that the errors are related to memory leakage of one form or the other, the problem can have several sources and be agitated by several programs.  I personally run the latest version on all my machines in a 24/7 capacity and have not run into the problem.  Some versions in the past created a similar error for me, yet the latest has not.  If you've already updated your IE's flash and that has not alleviated the problem, the only other solution is running an earlier release that doesn't crash for you or restart Skype more often.  I've had virtual video devices trigger this behavior by simply launching the video settings once.  The virtual device even when not in use continued to consume memory under Skype until it crashed.  So if you use any virtual audio/video components you may want to remove them to see if that changes anything.  Some people have also blocked ads when those were the source.
    http://community.skype.com/t5/Windows-desktop-clie​nt/low-storage/m-p/3974193/highlight/true#M344826

  • RoboCode crashes with SeedGenerator thread creation error?

    Hello everyone.
    I recently came across a game called RoboCode. It seems to be a tank battle simulator where you write the AI in Java.
    Unfortunately, it won't start on my Windows computers. I get this error:
    Exception in thread "SeedGenerator Thread" java.lang.InternalError: internal error: SeedGenerator thread creation error.
            at sun.security.provider.SeedGenerator$ThreadedSeedGenerator.run(Unknown Source)
            at java.lang.Thread.run(Unknown Source)Anyone got any idea why? I haven't the foggiest clue how to fix it or get around it - or even what it means.
    Thanks,
    -Kramy

    I'm awaiting a reply right now.
    But if Google couldn't turn up much, then it probably isn't a very common error? ;)

  • SPARC T4 - Dynamic Threading - Oracle Database

    i have a simple question about the new Sparc T4 line
    Can I use T4 running Oracle Database - RAC (Standard Edition)? Database is not recommended for T3 processors, oracle says "t (3) line is for applications, for database sparc M Line is more suitable " but this data sheet below says..
    "*Dynamic Threading*
    SPARC T4 is dynamically threaded. While software can activate up to eight strands on each core at a
    time, hardware dynamically and seamlessly allocates core resources such as instruction, data, and L2
    caches and TLBs, as well as out-of-order execution resources such as the 128-entry re-order buffer in
    the core. These resources are allocated among the active strands. Software activates strands by sending
    an interrupt to a HALTed strand. Software deactivates strands by executing a HALT instruction on
    each strand that is to be deactivated. No strand has special hardware characteristics. All strands have
    identical hardware capabilities."
    Whit this new feature... can i use oracle rac database on T4?
    Can someone help me please?
    tks,
    Robson

    I am not the most authorative person to answer this:
    Datasheets such as http://www.oracle.com/us/products/servers-storage/servers/sparc-enterprise/t-series/sparc-t4-2-ds-487859.pdf indicate the T4 for database workloads
    I guess you have alo found http://www.oracle.com/us/corporate/features/sparc-t4-announcement-494846.html
    Basically there are times with a database that a thread wants to do a lot of CPU work .... on a T3 this ends up on one thread on one of hte cores.
    On a T4 ... providing the core's are not fully utilitized, the thread requiring a lot of CPU should be allocated a whole core to itself .... and run much more quickly.
    So for instance starting or upgrading a single databse on a T4 should run much much faster on T4 as opposed to T3. And that probably is the case of a failover also.
    Anyway to give a couple of not so simple answers (and these are my personal answers):
    - Can one use a T3 for RAC .... yes but it iisn't recommended and failover and other operations may be lenghtly.
    - Can one use a T4 for RAC .... yes ... it will certainly outperform a T3. Is it recommended ... (pass ... ask the salesman).
    ... I am happy for others to add comments.

  • Dynamic Tray creation at runtime

    hi experts,
    we have a requirement where we are showing employee details in the tray UI element.
    we have 1 tray at design time showing employee details obtained from a Bapi.
    Now we need to display spouse details(if available) and children details(their number can be any~known at runtime) in seperate trays. eg each tray for 1 person..so if there are 6 children, there are 8 trays including one for employee and spouse...
    Now what I need is the source code  or method to dynamically generate tray at runtime along with the labels and textviews they contain..
    thanks in advance

    HI,
    solved the problem....
    i was doing some search here and there and finally got the code to do it. when i came back to the thread i found Ramesh suggested the same stuff which i had used.
    thanks gurus.
    I am writing my code here for other people looking for the same thing:
    IWDTransparentContainer container =(IWDTransparentContainer)view.getElement("RootUIElementContainer");
         wdContext.currentContextElement().setIpvalue("Demo Name");   //this is my context attribute.
    for(int i=1;i<3;i++)
         IWDTray tray=(IWDTray)view.createElement(IWDTray.class,null);
                   tray.setExpanded(false);
                   tray.setWidth("700px");
                   IWDLabel label=(IWDLabel)view.createElement(IWDLabel.class,null);
                   label.setText("your name is");
              IWDTextView textview1=(IWDTextView)view.createElement(IWDTextView.class,null);
              textview1.setText(wdContext.currentContextElement().getIpvalue());
              IWDLabel label1=(IWDLabel)view.createElement(IWDLabel.class,null);
              label1.setText("Employee age");
         IWDCaption caption =(IWDCaption)view.createElement(IWDCaption.class,null);
         caption.setText("WElcome to employee information");
                   tray.setHeader(caption);
         IWDLayout layout=(IWDLayout)tray.createLayout(IWDMatrixLayout.class); //setting tray layout to matrix
         IWDLayoutData layout1=(IWDLayoutData)label1.createLayoutData(IWDMatrixHeadData.class);
         tray.addChild(label);
         tray.addChild(textview1);
         tray.addChild(label1);
                   container.addChild(tray);
    P.S. Awarding points to Ramesh.

  • Dynamic Event Creation and Handling the events

    Hi All
    I am using WAS 6.4.
    I have two components say Component A and Component B in which Component A is a reusable component and is used by other components say for e.g the Component B.
    The following is the requirement.
    Component A should create buttons for other components dynamically.
    As an example, Component B specifies to Component A the buttons required say button B1 and button B2.
    Component B also contains methods M1 and M2 for the buttons created by the component A.
    Now I would like to associate these buttons created by component A with the methods created in Component B
    The number of buttons that are to be created may vary from component to component.
    If any one as any suggestion or solution, help me out.
    Thanks
    Regards
    NagaKishore

    Hi NagaKishore,
         I'm not exactly sure why you want to do this, but it is pretty easy if I switch it up a bit.  (Maybe you are trying to create a navigation page or something?) 
         Instead of your component B using component A, if you define a Web Dynpro interface in component A, then implement this interface in component B (or all component Bs), achieving your goal would not be too difficult.  It could define a generic method (or event) with a "button key" as an argument that would tell component B which button was pressed and allow it to behave as desired.  The Web Dynpro interface defined in A could also have an interface context that would allow the the button text to be passed along with (for the sake of simplicity) a "button key" that component that should be triggered when the button is pressed.  (Note this could be a varying size list as required.)
         The component B(s) need not be known until run-time.  They can be created using something like:
    wdThis.wdGet<Used Compontne Name>ComponentUsage().createComponent(<Component Name>,<Object Name (if in a different component)>)
         Once the component is created, the context can be accessed giving the list of buttons to create and the values.  The buttons can be created in the wdModifyView during the first pass of the creation of the view displaying the buttons (after the dynamic creation of the used components which can occur in the wdDoInit of the component controller).
         If the user presses a chosen button on component A, then the generic method (most likely an event) of component Bs interface is called and passed the "button key", component B then takes over.  Note this would also work if component B had a visualization component that must be displayed through an interface view that is defined on the web dynpro component interface that is implemented by B.
         Hope this helps or at least triggers discussion that will answer your question,
           --Greg

  • AFAB dynamic variant creation for Posting period.

    HI,
    Business Requirement :
    Business want to run AFAB transaction code every month automatically with schedule job.
    system should pick present month period in posting period field.
    i checked in variant creation  against posting period there is no dynamic " D " in selection variable column.
    how can i fix this.

    Hi Jani,
    Check with abaper if TVARV table can Help you in this case, or create a z program from AFAB. And add date field to it, and schedule job based on that,
    I think TVARV table will be a better approach.
    Another point to consider here would be that dep should be run once business is ready to do so, and has its own hick ups in business if corrections are required to be made after executing AFAB by job
    Regards
    Pankaj B.

  • "Pause" Thread, thread creation & run performance

    Hello,
    I'm having an object executing tasks in response to events (I call it Executer)
    In "normal" execution mode, it's executing 2 types of tasks: tasks1 and tasks2.
    when a specific event occurs (pauseEvent), I want it to STOP executing tasks2 for a specific amount of time (in this example 100ms): I'm calling that a "pause"
    it will still be executing tasks1 in the meantime, and will resume executing tasks2 only after the pause has expired.
    to do so, when I receive a pauseEvent I create a new Thread (PauseThread) and start it.
    it itself calls the "setPause(boolean p)" method of Executer to set the "pause" flag to true
    then it waits for 100ms
    then it sets back the pause flag to false
    (Executer checks the pause flags before executing tasks2)
    class PauseThread extends Thread {
        private TaskExecuter  executer;
        private long                pauseTime;
        public PauseThread(Executer e, int t) {
            executer = e;
            pauseTime = t;
        public void run() {
            executer.setPause(true);
         try {
                sleep(pausetime);
            catch(InterruptedException e) {
                System.out.println("exception pause thread");
         executer.setPause(false);                
    }all is working fine.
    however, I'm trying to improve performances.
    the whole process of creating & starting the thread takes up to 50us, I want to reduce this as much as possible.
    obviously, I create & start a thread every time I want to do a pause, I'm thinking there MUST be a way to avoid this, and simply call the setTrue / Sleep / setFalse part of the thread instead.
    I was thinking about creating and starting the thread only once at the creation of my Executer, and calling the "pause()" method when needed:
    class PauseThread extends Thread {
        private TaskExecuter  executer;
        private long                pauseTime;
        public PauseThread(Executer e, int t) {
            executer = e;
            pauseTime = t;
        public void run() {
         while(true) {
        public void pause() {
            executer.setPause(true);
         try {
                sleep(pausetime);
            catch(InterruptedException e) {
                System.out.println("exception pause thread");
         executer.setPause(false);                
    }would that be correct ?
    I'm concerned with the performance hit of the "while(true)" (as I'm fighting for micro-seconds, even the slighliest useless cpu hit should be avoided)
    what if I had "sleep(1)" in my while loop ?
    I'm pretty sure there's a better way to do this, any idea ? maybe using wait / notify, however I get the feeling those methods are not designed for this use...
    any hint ?
    thanks !

    yes, I'm certainly reinventing the wheel ! but trying to understand it at the same time !
    what was your other suggestion ? Timer + TimerTask ? I've already implemented it and using it now ! as I said it's working good, 3x improvement ! simply trying to see if there's a way to avoid creating a TimerTask object at each run.
    coming back at the "piece of nonsense", what would this achieve:
    class PauseThread extends Thread {
        private TaskExecuter  executer;
        private long                pauseTime;
        private boolean           flag = false;
        public PauseThread(Executer e, int t) {
            executer = e;
            pauseTime = t;
        public void run() {
         while(true) {
                if(flag) {
                    flag = false;
                    sleep(pauseTime); // add try/catch
                    executer.setPause(false);
        public void startPause() {
            flag = true
    }then in my Executer, I create and start the PauseThread only once, and when I want to pause it, I simply do:
    setPause(true);
    pauseThread.startPause();in this case the sleep would execute in the run(), pause the "pause" thread, not the "executer" thread, no ?
    I will read about the concurrency classes...

Maybe you are looking for