Passing objects to running threads..

May anybody give me an idea on how to pass an object to an already running thread??
i only know how to pass an object to the thread's constructor.

I guess you are trying to assign a variable dynamically. What you can do is a keep a reference in your thread class (you may have probably done it because you have mentioned about passing an object to your threads constructor). Then give a public setter method to assign an object to that variable. Then you can change that even after you invoke start() of your Thread object.
example:
public class MyThread extends Thread{
private Object obj;
public void setObject(Object obj){
this.obj = obj;
public void run(){
//your code for the thread
Then from the class you invoke the thread you can do the following:
MyThread t = new MyThread();
t.start();
Object obj = "your object";
t.setObject(obj);
Note: However if your thread is not alive when you assign the object then there will be no use of the passed object to the code inside run() method

Similar Messages

  • How to pass a "user defined" object to a thread?

    Hi...
    I have created an object say 'obj1' . I want to pass to a thread say 'T1' .
    The thread T1 implements the runnable class.
    I need to pass the "obj1" object to the T1 for it to be processed in the "run" method of T1.
    As far as I have seen there is no thread constructor in Java that accepts an object created by the user.
    My question is there any way to pass an object to a thread? and if so how can it be done?

    You can just add your own method to the class. Then call that method to pass the object to the thread before you call start on the thread.
    class MyThread implements Runnable
       public void run()
          userObj.whatever();
       public void addObj(Object obj)
          userObj = obj;
       Object userObj = null;
    // your code
    MyThread thread = new MyThread();
    thread.addObj(myObj);
    thread.start();As long as you don't call start before your pass the object to your thread, then you won't have a problem. Hope this helps.

  • Yet Another "Passing Objects" Thread

    Hi All,
    Quick question about passing objects:
    I have three classes - ClassA, ClassB and ClassC. Lets say I create an object of ClassA in ClassB. Also, I would like to send the ClassA object from ClassB to ClassC to update its data. My question is, can I set the ClassA object in ClassC and modify it through ClassB? Confusing? I'll try to create an example below.
    ClassA:
    public class ClassA {
           // data
    } ClassB: creates and calls update methods for ClassA object
    public class ClassB {
           ClassA object = new ClassA();
           // print object
           ClassC ClassCFacade = new ClassC();
           ClassCFacade.setClassAObject(object);
           ClassCFacade.updateClassAObject(object);
           // print object
    }ClassC: updates object
    public class ClassC {
          // set object
          public void setClassAObject(ClassA object) {
                   // sets object
          // get object
          public ClassA getClassAObject() {
                  // returns object
          // modify object
          public updateClassAObject() {
                ClassA o = getClassAObject()
                // modify o
                setClassAObject(o)
    }So if objects are passed by reference, handle, or whatever you call it, essentially the above code should modify ClassA object created in ClassB, meaning the ClassA object should display it was modified after second print in ClassB. Although I've tried this implementation and the ClassA object is not modified after updateClassAObject method call from ClassB.
    Any input would be appreciated.
    Thanks,
    Bob

    OK. Here's snippets of actual code:
    public class ClassA implements SessionBean, ClassARemoteBusiness {
        // ClassA Attributes
        Integer ID;
        String name;
        // SET METHODS
        public void setClassAID(Integer ID) {
            this.ID = ID;
        public void setClassAName(String name) {
            this.name = name;
        // GET METHODS
        public Integer getClassAID() {
            return ID;
        public String getCLassAName() {
            return name;
    import classa.ClassA;
    import classc.ClassC;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class ClassB extends HttpServlet {
        private ClassA object;   
        private ClassC ClassCFacade;
        private ClassCFacade = lookupClassCBean();
        protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
              HttpSession session = request.getSession();           
              // display object values - displays default values
              out.println("ID: " +object.getClassAID());
              out.println("Name: " +object.getClassAName());
             // update object
             ClassCFacade.setClassAObject(object);
             ClassCFacade.updateClassAObjectID(someInteger);
             ClassCFacade.updateClassAObjectName(someName);
              // display object values - displays updated values
              out.println("ID: " +object.getClassAID());
              out.println("Name: " +object.getClassAName());
        // LOOKUP METHODS
        private web.ServiceLocator serviceLocator;
        private web.ServiceLocator getServiceLocator() {
            // service locator code
        private classc.ClassCRemote lookupClassCBean() {
            // lookup code       
    import classa.ClassA;
    public class ClassC implements SessionBean, ClassCRemoteBusiness {
        private ClassA o;
        // SET METHODS
        public void setClassAObject(ClassA object) {
            o = object;
        // UPDATE
        public void updateClassAObjectID(Integer ID) {
            o.setClassAID(ID);
        public void updateClassAObjectName(String name) {
            o.setClassAName(name);
    }

  • Passing objects by reference in PL/SQL

    Hi,
    I have come across an unexpected problem using object types in PL/SQL that is causing me some grief. I'm from a Java background and am relatively new to Oracle Objects but what I'm trying to do is fairly trivial, I think. The code below illustrates the problem.
    --- cut here ---
    CREATE OR REPLACE TYPE test_obj_t AS OBJECT
    num INTEGER,
    CONSTRUCTOR FUNCTION test_obj_t RETURN SELF AS RESULT
    CREATE OR REPLACE TYPE BODY test_obj_t IS
    CONSTRUCTOR FUNCTION test_obj_t RETURN SELF AS RESULT IS
    BEGIN
    num := 0;
    RETURN;
    END;
    END;
    CREATE OR REPLACE PACKAGE test_obj_ref AS
    PROCEDURE init(o IN test_obj_t);
    PROCEDURE inc;
    FUNCTION get_num RETURN INTEGER;
    END;
    CREATE OR REPLACE PACKAGE BODY test_obj_ref IS
    obj test_obj_t;
    PROCEDURE init(o IN test_obj_t) IS
    BEGIN
    obj := o;
    END;
    PROCEDURE inc IS
    BEGIN
    obj.num := obj.num + 1;
    END;
    FUNCTION get_num RETURN INTEGER IS
    BEGIN
    RETURN obj.num;
    END;
    END;
    --- cut here ---
    The object type test_obj_t holds a integer and the test_obj_ref package holds a 'reference' to an instance of the object.
    To test the above code I run this PL/SQL block:
    declare
    obj test_obj_t;
    begin
    obj := test_obj_t;
    test_obj_ref.init(obj);
    dbms_output.put_line('obj.num='||obj.num);
    dbms_output.put_line('test_obj_ref.get_num='||test_obj_ref.get_num);
    test_obj_ref.inc;
    dbms_output.put_line('obj.num='||obj.num);
    dbms_output.put_line('test_obj_ref.get_num='||test_obj_ref.get_num);
    test_obj_ref.inc;
    dbms_output.put_line('obj.num='||obj.num);
    dbms_output.put_line('test_obj_ref.get_num='||test_obj_ref.get_num);
    end;
    giving the output:
    obj.num=0
    test_obj_ref.get_num=0
    obj.num=0
    test_obj_ref.get_num=1
    obj.num=0
    test_obj_ref.get_num=2
    It appears that the object held by the test_obj_ref package is being incremented as expected, but I would have expected the object declared in the PL/SQL block to be pointing to the same object and so should report the same incremented values.
    I suspect that the object is copied in the call to test_obj_ref.init() so I end up with two object instances, one that is held by the test_obj_ref package and one in the anonymous block. Although, I thought that all IN parameters in PL/SQL are passed by reference and not copied!
    Am I right?
    Is passing objects by reference possible in PL/SQL, if so how?
    I'm using Oracle 10.2.0.3.
    Cheers,
    Andy.

    the object being passed to the test_obj_ref.init+ procedure is passed by reference; however, when you assign it to your package variable obj it is being copied to a new instance. you can pass object instances as parameters to procedures using the +IN OUT [NOCOPY]+ *calling mode, in which case modifications to the attributes of the passed object will be reflected in the calling scope's instance variable.
    oracle's only other notion of an object reference is the +"REF <object-type>"+ datatype, which holds a reference to an object instance stored in an object table or constructed by an object view.
    hope this helps...
    gerard

  • How to build sql query for view object at run time

    Hi,
    I have a LOV on my form that is created from a view object.
    View object is read-only and is created from a SQL query.
    SQL query consists of few input parameters and table joins.
    My scenario is such that if input parameters are passed, i have to join extra tables, otherwise, only one table can fetch the results I need.
    Can anyone please suggest, how I can solve this? I want to build the query for view object at run time based on the values passed to input parameters.
    Thanks
    Srikanth Addanki

    As I understand you want to change the query at run time.
    If this is what you want, you can use setQuery Method then use executeQuery.
    http://download.oracle.com/docs/cd/B14099_19/web.1012/b14022/oracle/jbo/server/ViewObjectImpl.html#setQuery_java_lang_String_

  • Long running threads.

    Hello everyone,
    Thanks for your interest in this post. I have a design question on a feature we are currently working on - I have described it below as best as I can. I would be thankful for any direction or guidance from all the good and experienced folks here in this forum :)
    We have a system which receives some input data (say in the form of files or a db update) from external sources. We have a job which wakes up periodically, checks for the presence of new data and then does some parsing/data manipulation. I have posted it below and for the sake of brevity and conciseness kept it simple.
    public class Work{  
        private SomeVar _var;  
        //constructor here  
        public void doWork(){  
             //run job  
    }  Note we have multiple kind of input (so multiple Work classes each of which have different parse logic).
    So far so good.
    We have jdk 1.4 (no java.util.concurrent) and we dont have an option to use a scheduling f/w like quartz
    Its simple enough and we dont have a need for Listeners, dynamic scheduling etc.
    That leaves us with 2 options to implement this
    Option 1
    Create a thread for each kind of job on startup.
    Each thread checks for presence of input data and creates a Work object to process the job.
    public class WorkThread extends Thread{//some common functionality here}
    public class SpecificWorkThread extends WorkThread{  
           private MetaInfo _meta;  
           //constructor  
           public void run(){  
              while(true){  
                    //check for presence of input data  
                    Work _w = new Work();  
                    _w.doWork();  
                    //sleep for some time  
    pulic class Controller{
          psv main(String args[]){
         //for each job{
                 WorkThread t = new SpecificWorkThread();
                 t.start();
             //join on all threads
    }  As you can see this would create (from the main), a long running thread for each job type
    Option 2
    Have the input data check in the controller clas. When there is input data to parse, create a Thread which does the parsing.
    The thread in its run method parses and comes out. So for each parse cycle, a short lived thread is created, somthing like below
    public class WorkController{  
           psv main(String args[]){  
                   while(true){  
                      //check for input condition  
                      new SpecificWorkThread(new Work()).start();  
                     //sleep for sometime  
              public class SpecificWorkThread extends Thread{  
                  private Work _work;  
                  //constructor  
                  public void run(){  
                        _work.doWork();  
            The difference between the two is that while the first creates long running threads per job type, in option(2) a thread is created on demand. Each thread is short lived (it does its job and dies), but then a thread needs to be created every time for a job.
    Both would work and work correctly. What I would like to understand is if the options presented above just a programmer's prefence or is one option better than the other (performance, memory considerations) etc?
    Thanks for your patience in reading this post.
    cheers,
    ram.

    Generally creating a new thread is an expensive process. Well, everything is relative. My laptop can create & run & stop 7,000+ threads per second, test program below, YMMV. If you are dealing with thousands of thread creations per second, pooling may be sensible; if not, premature optimization is the root of all evil, etc.
    public class ThreadSpeed
        public static void main(String args[])
         throws Exception
            System.out.println("Ignore the first few timings.");
            System.out.println("They may include Hotspot compilation time.");
            System.out.println("I hope you are running me with \"java -server\"!");
         for (int n = 0; n < 5; n++)
             doit();
            System.out.println("Did you run me with \"java -server\"?  You should!");
        public static void doit()
         throws Exception
            long start = System.currentTimeMillis();
            for (int n = 0; n < 10000; n++) {
             Thread thread = new Thread(new MyRunnable());
             thread.start();
             thread.join();
            long end = System.currentTimeMillis();
            System.out.println("thread time " + (end - start) + " ms");
        static class MyRunnable
         implements Runnable
         public void run()
    }Edited by: sjasja on Jan 14, 2010 2:20 AM

  • How to close all running threads

    I have many threads running everywhere in my application. when i disconnect from server, all sockets between me and the server must disconnect. but since different threads are having a socket connection each to the server, i cant close them all, since i dont have the reference to the diff thread objects.
    how do i close these sockets (each whole thread) ?
    Regards,
    Sid

    Thanks for replying.
    but i figured out the way last night itself.
    i was trying to fire a text changed event and putting a listener for it in every running thread so that when i want to disconenct, i would write some text into the textbox which would fire the event and the threads would listen to itr and kill themselves. but it simply wasnt workin.
    then i came across the class ThreadGroup. add each thread to that threadgroup adn say ThreadGroup.stop();
    Thanks anyway.
    Regards,
    Sid

  • Pass object to xslt stylesheet and invoke its methods

    I'd like to pass an external created object to a xslt stylesheet to dynamically modify the xslt file at run time. After searching around for weeks, I'm really desperate.
    I used Xalan transformer's method setParameter(name, obj) to initialize a variable in xslt file with this object. Then the object's method was invoked.
    The class that I want to invoke the method:
    class test{
    private String testString = "abc";
    public String valueOf(){
    return testString;
    xslt file:
    <xsl:param name="myType"></xsl:param>
    <<xsl:variable name="new-pop"
    select="my-class:valueOf($myType)">
    Any help is greatly appreciated.
    Thank you.
    Message was edited by:
    Orbital
    Message was edited by:
    Orbital

    Thank sabre. I have looked through your link.
    The problem is for all the info I knew, we can only
    create a new object inside the stylesheet using new()
    and then invoke this particular object's instance
    method.
    However, I want to pass an already created java
    object into the stylesheet and then invoke its
    method.
    Xalan seems to not allow this. I have tried to pass
    an object as the parameter of
    transformer.setParameter(name, object) but it doesn't
    work.
    Any one know what 3rd party transformer that allow to
    pass object directly into xslt?setParameter will work... in your XSL, you should have
    <xsl:param name="myParam" />set the parameter in your transformer like what you had in your post...
    In your XSL header, you must declare the your Java object namespace and path, such as:
    xml:myJavaObject= "com.MyCompany.MyJavaObject"then in your template or anywhere that you want to use your object, you should have:
    <xsl:variable name="runningMyMethod" select="myJavaObject:myJavaMethod($myParam)" />The XSL will treat $myParam as the instance object, if there is any other method parameters needed to be passed in do:
    <xsl:variable name="runningMyMethod" select="myJavaObject:myJavaMethod($myParam, 'blah', 'blah')" />Good luck.

  • Accessing Object using mutliple threads

    I created a class that creates 2 threads and both thread calls a method ( not synch..). In the method i create a new object.
    Here is the code for it.
    class ggh{
        public void m1(){
            ss s1= new ss();      // Simple class having 2 fields(int and string) and their getter setters
            System.out.println("S1 for thread #" + Thread.currentThread().getName() + "  ==> " + s1.toString()  );
            if(Thread.currentThread().getName().equals("Thread-0"))  // thread #1
                try {
                    Thread.sleep(1000);      // -------------> 1
                s1.setA(2);                           // --------------> 2
                System.out.println("Settin s1 = null " + Thread.currentThread().getName());
                    s1 = null;                         //  ---------------> 3
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
            System.out.println("s1 a==>" + s1.getA() + "::" + Thread.currentThread().getName() + " :: " + s1.toString());         //----------------> 4
        public static void main(String[] args) {
            final ggh g1 = new ggh();
            Thread t1 = new Thread(){
                public void run(){
                    g1.m1();
            Thread t2 = new Thread(){
               public void run(){
                        g1.m1();
            t1.start();
            t2.start();
    }when i execute this code, my output is totally unpredictable. Here are some of the outputs i got.
    ************** 1 The code creates the same object for both threads
    S1 for thread #Thread-0 ==> vom.cdd.ss@defa1a
    S1 for thread #Thread-1 ==> vom.cdd.ss@defa1a
    s1 a==>1::Thread-1 :: vom.cdd.ss@defa1a
    Settin s1 = null Thread-0
    java.lang.NullPointerException
         at vom.cdd.ggh.m1(ggh.java:39)
         at vom.cdd.ggh$1.run(ggh.java:46)
    ************** 2 objects are different now.
    S1 for thread #Thread-0 ==> vom.cdd.ss@f5da06
    S1 for thread #Thread-1 ==> vom.cdd.ss@defa1a
    s1 a==>1::Thread-1 :: vom.cdd.ss@defa1a
    Settin s1 = null Thread-0
    java.lang.NullPointerException
         at vom.cdd.ggh.m1(ggh.java:39)
         at vom.cdd.ggh$1.run(ggh.java:46)
    ************* 3 [Here nullpointer exception occurs before the null message is printed[/b]
    S1 for thread #Thread-0 ==> vom.cdd.ss@defa1a
    S1 for thread #Thread-1 ==> vom.cdd.ss@defa1a
    s1 a==>1::Thread-1 :: vom.cdd.ss@defa1a
    java.lang.NullPointerException
         at vom.cdd.ggh.m1(ggh.java:39)
         at vom.cdd.ggh$1.run(ggh.java:46)
    Settin s1 = null Thread-0
    So my question here is :
    when such kind of unsynch. access occurs for some method. then does there exists a different object [b]( a new memory is allocated ) for each thread
    or does there exist only one object and each thread has a different reference to it, and the thread can manipulate its properties.
    Or does there exist a different explanation for this kind of behaviour??
    One more thing, i dont wnat the method/a block of code to be synchronized.
    I also have another doubt but willl post it after this one get's cleared.
    Thanks in advance.
    Regards
    Akshat Jain

    2 objects are different nowThey are not different at all. Address can differ at
    each invocation.What do u mean that they are not different at all.
    if they have different object's then obviously their address are different and henc the objects too.
    am i getting this wrong??

  • Long running threads (Jasper Reports) and AM-Pooling

    Hi,
    we are developing quite large application with ADF an BC. We have quite a lot of reports generated through Jasper that take quite long time to complete. The result is a PDF document that user gets on the UI so he can download it over download link. Reports that take over an hour to finish are never completed and returned to the user on UI. I think the problem is in AM-Polling because we are using default AM-Polling settings:
    <AM-Pooling jbo.ampool.maxinactiveage="600000" jbo.ampool.monitorsleepinterval="600000" jbo.ampool.timetolive="3600000"/>
    The AM is destroyed or returned to pool before reports finishes. How to properly configure those settings that even long running threads will do there jobs to the end.
    We also modified web.xml as follows:
      <session-config>
        <session-timeout>300</session-timeout>
      </session-config>
    Any help appreciated.
    Regards, Tadej

    Your problem is not related to ADF ApplicationModules. AMs are returned to the pool no earlier than the end of request, so for sure they are not destroyed by the framework while the report is running. The AM timeout settings you are referring to are applicable only to idle AMs in the pool but not to AMs that have been checked out and used by some active request.
    If you are using MS Internet Explorer, then most probably your problem is related to the IE's ReceiveTimeout setting, which defines a timeout for receiving a response from the server. I have had such problems with long running requests (involving DB processing running for more than 1 hour) and solved my problem by increasing this timeout. By default this timeout is as follows:
    IE4 - 5 minutes
    IE5, 6, 7, 8 - 60 minutes
    I cannot find what the default value is for IE9 and IE10, but some people claim it is only 10 seconds, although this information does not sound reasonable and reliable! Anyway, the real value is hardly greater than 60 minutes.
    You should increase the ReceiveTimeout registry value to an appropriate value (greater than the time necessary for your report to complete). Follow the instructions of MS Support here:
    Internet Explorer error &quot;connection timed out&quot; when server does not respond
    I have searched Internet for similar timeout settings for Google Chrome and Mozilla Firefox, but I have not found anything, so I instructed my customers (who execute long-running DB processing) to configure and use IE for these requests.
    Dimitar

  • Passing object as parameter in JSF using h:commandLink tag

    Hi ,
    I have a scenario in which i need to pass objects from one jsp to another using h:commandLink. i read balusC article "Communication in JSF" and found a basic idea of achieving it. Thanks to BalusC for the wonderful article. But i am not fully clear on the concepts and the code is giving some error. The code i have is
    My JSP:
    This commandlink is inside a <h:column> tag of <h:dataTable>
    <h:commandLink id="ol3"action="ManageAccount" actionListener="#{admincontroller.action}" >
                   <f:param id="ag" name="account" value="#{admincontroller.account}" />
                   <h:outputText id="ot3" value="Manage Account" rendered="#{adminbean.productList!=null}" />
                   </h:commandLink>
    Also a binding in h:dataTable tag with the  binding="#{admincontroller.dataTable}"
                      My Backing Bean:
    public class CompanyAdminController {
              private HtmlDataTable dataTable;
              private Account account=new Account();
    public HtmlDataTable getDataTable() {
            return dataTable;
    public Account getAccount() {
             return this.account;
    public void setAccount(Account account) {
              this.account = account;
          public void action(){
                account= (Account)this.getDataTable().getRowData();
           } faces-config.xml
    <navigation-rule>
        <from-view-id>/compadmin.jsp</from-view-id>
        <navigation-case>
          <from-outcome>ManageAccount</from-outcome>
          <to-view-id>/manageAccount.jsp</to-view-id>
        </navigation-case>
      </navigation-rule>
    <managed-bean>
              <managed-bean-name>admincontroller</managed-bean-name>
              <managed-bean-class>com.forrester.AdminController</managed-bean-class>
              <managed-bean-scope>request</managed-bean-scope>
              <managed-property>
                   <property-name>account</property-name>
                   <property-class>com.model.Account</property-class>
                   <value>#{param.account}</value>
             </managed-property>
         </managed-bean>My account object:
    public class Account {
    string name;
      public String getName()
        return this.name;
      public void setName(String name)
           this.name=name;
      }I need to display #{admincontroller.account.name} in my forwarded jsp. But I am not sure whether the code i wrote in commandlink is correct. I get an error if i use <f:setActionListener> . No tag "setPropertyActionListener" defined in tag library imported with prefix "f"
    Please advise.
    Edited by: twisai on Oct 18, 2009 11:46 AM
    Edited by: twisai on Oct 18, 2009 11:47 AM
    Edited by: twisai on Oct 18, 2009 11:48 AM

    Yes.. iam removed the managedproperty from faces-config. But still i get the null pointer exception on main jsp itself and i am taken to second jsp manageaccount.jsp. Did you find anything wrong in my navigation case in the action method??
                                     public String loadAccount(){
               Account account = (Account)this.getDataTable().getRowData();
                return "ManageAcct";And also can you please answer this question i have
    The AdminController is the backing bean of 1st JSP and manageAccontController is the backing bean of forwarded JSP .
    Can i put this action method and dataTable binding in a 2nd manageAccontController backing bean instead of AdminController. But if i do that way dataList binding in h:dataTable tag will be in first JSP backing bean and dataTable binding to 2nd JSP. Not sure how to deal with this.
    {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • URGENT: How to run threads in sequence?

    Dear experts, I am new to writing threads. I would like to know how to run threads in sequence? How do I know when a thread finishes its task?
    In the following code, classes Process_A(), Process_B(), Process_C() and Process_D() are subclasses of Class Thread.
    I'd like to know if I am using the join() function correctly? My intention is to wait for the previous process to finish before running the current process.
    Could anyone kindly give me some solutions on how to run the processes in sequence?
    Thanks!!
    =============================================================
    Thread process;
    Vector process_names = new Vector();
    process_names.add("a");
    process_names.add("b");
    process_names.add("c");
    for(int i=0; i<process_names.size(); i++)
    String process_name = (String) process_names.elementAt(i);
    if(process_name.equals("a"))
    process = new Process_A();
    else if(process_name.equals("b"))
    process = new Process_B();
    else if(process_name.equals("c"))
    process = new Process_C();
    else if(process_name.equals("d"))
    process = new Process_D();
    timer = new javax.swing.Timer(1000, new ProcessListener());
    timer.start();
    // ProcessListener()
    class ProcessListener implements ActionListener {
    public void actionPerformed(ActionEvent evt) {
    if(process!=null)
    if(process.isAlive())
    try
    process.join();
    catch(Exception ex)
    ex.printStackTrace();
    process.start();

    just look at this simple example u will get to know how to use join method
    This does exactly what u want
    class callme
    void call(String msg)
    System.out.println("["+msg);
    Try
    Thread.sleep(1000);
    catch(InterruptedException e)
    System.out.println("interrupted");
    System.out.println("]");
    class caller implements Runnable
    String msg;
    Callme target;
    Thread t;
    Public Caller(Callme targ, String s)
    target=targ;
    msg=s;
    t=new Thread(this);
    t.start();
    public void run()
    target.call9msg);
    class Synch
    public static void main(String arg[])
    Callme target=new Callme();
    Caller ob1=new Caller(target,"hello");
    Caller ob2=new Caller(target,"Synchronized");
    Caller ob3=new Caller(target,"world");
    Try
    ob1.t.join();
    ob2.t.join();
    ob3.t.join();
    catch(InterruptedException e)
    System.out.println("interrupted");
    waiting for dukes

  • How to get class name of a object in run time, from its accessible context.

    Hi,
    I need to get the class name of a java object in run-time, given the AccessibleContext of that object.
    I gone through the AccessibleContext api documentation. but there is not way to get the class name for a java object using its AccessibleContext object.
    Do any one have any idea how to get the class name of an java object, given its accessible object Accessible.
    Thanks
    Timberlake

    816311 wrote:
    Please try to provide a solution for my requirement and avoid evaluating a requirement.
    I am a curious guyit's great to be curious. however, in this situation, the requirement makes no sense in the given context. so, in an effort to be helpful, the people on this forum are asking you the reason behind the requirement. the reason we do this is because we have experience answering questions on this forum and, more often than not, requirements which don't make sense are the result of misunderstandings or confusion on the part of the person making the requirement. if we can figure out why you want to do what you want to do, we may be able to point you in a direction which makes more sense.

  • Memory leak problem while passing Object to stored procedure from C++ code

    Hi,
    I am facing memory leak problem while passing object to oracle stored procedure from C++ code.Here I am writing brief description of the code :
    1) created objects in oracle with the help of "create or replace type as objects"
    2) generated C++ classes corresponding to oracle objects with the help of OTT utility.
    3) Instantiating classes in C++ code and assigning values.
    4) calling oracle stored procedure and setting object in statement with the help of setObject function.
    5) deleted objects.
    this is all I am doing ,and getting memory leak , if you need the sample code then please write your e-mail id , so that I can attach files in reply.
    TIA
    Jagendra

    just to correct my previous reply , adding delete statement
    Hi,
    I am using oracle 10.2.0.1 and compiling the code with Sun Studio 11, following is the brief dicription of my code :
    1) create oracle object :
    create or replace type TEST_OBJECT as object
    ( field1 number(10),
    field2 number(10),
    field3 number(10) )
    2) create table :
    create table TEST_TABLE (
    f1 number(10),f2 number (10),f3 number (10))
    3) create procedure :
    CREATE OR REPLACE PROCEDURE testProc
    data IN test_object)
    IS
    BEGIN
    insert into TEST_TABLE( f1,f2,f3) values ( data.field1,data.field2,data.field3);
    commit;
    end;
    4) generate C++ classes along with map file for database object TEST_OBJECT by using Oracle OTT Utility
    5) C++ code :
    // include OTT generate files here and other required header files
    int main()
    int x = 0;
    int y = 0;
    int z =0;
    Environment *env = Environment::createEnvironment(Environment::DEFAULT);
    Connection* const pConn =
    env->createConnection"stmprf","stmprf","spwtrgt3nms");
    const string sqlStmt("BEGIN testProc(:1) END;");
    Statement * pStmt = pConn->createStatement(sqlStmt);
    while(1)
    TEST_OBJECT* pObj = new TEST_OBJECT();
    pObj->field1 = x++;
    pObj->field2 = y++;
    pObj->field3 = z++;
    pStmt->setObject(1,pObj);
    pStmt->executeUpdate();
    pConn->commit();
    delete pObj;
    }

  • Hoe to pass object as a parameter thru webSerive

    I need to pass Object as a parameter to web service:
    example:
    public calss returnCodes{
    int ret_code;
    String ret_string;
    public retrunCodes(int ret_code, String ret_string){
    this.ret_code = ret_code;
    this.ret_string = ret_string;
    public int getret_code()
    return this.ret_code;
    public String getret_string {
    return this,ret_string
    and other repc holder class to hold returnCodes
    public class retrunCodesHolder implents javax.xml.rpc.Holder
    returnCode value;
    pubic returnCodesHolder(){
    public returnCodesHolder(returnCodes value) {
    this.value = value;
    In Webservice I use returnCodesHolder as parameter.
    WebService getReturnCodesWs I have
    returnCodes retCodes = new returnCodes(04,"Good return code)
    returnCodesHolder retholder = new returnCodesHolder(retCodes)
    return myString;
    When I am calling above webService in servlet I have code:
    org.test.mytest.returnCodesHolder retHolder = new org.test.mytest.returnCodesHolder();
    String result = port.getReturnCodesWs(retHolder);
    How to I access /get values of returnCodes class in my calling servlet?
    I am using Tomcat v 6.0

    I believe (although have never used, so if I'm wrong,
    correct me please!) you can do it with implicit
    dynamic cursors, such as:
    For rec in 'select col1, col2 from table 1 '||lstr
    loop
    Not really:
    michaels>  declare
       lstr   varchar2 (30) := ' where empno = 7788';
    begin
       for rec in 'select * from emp e ' || lstr
       loop
          null;
       end loop;
    end;
    Error at line 1
    ORA-06550: line 5, column 4:
    PLS-00103: Encountered the symbol "LOOP" when expecting one of the following:
       . ( * @ % & - + / at mod remainder rem .. <an exponent (**)>
       ||

Maybe you are looking for

  • Apple ID is not working

    apple ID is not working

  • Starcraft 2 patch 1.3

    there is some 3d rendering glitch going on. everything its messed up. im not sure if it was patch 1.3 or something else that got updated. but im on the most current nvidia drivers and wine version. heres what i get when i try and run it: [lnxusr@myho

  • Error in unzipping the downloaded file

    I am having problems in unzipping the downloaded oracle personal version 8i file. Server name : PC pentium II intel File name : psoracle81798 Date/Time : 07/10/2002 9.50 pm ET Browser : IE O/S : Windows 98 Error Msg : the unzip software programs give

  • Document type authorisation

    Hii . I want some of my users to avoid psotings to document type SA ,please guide hot wo do that. Wiating for your feedback. Cheers.

  • Can the Adapter Charger on MuVo2 FM be used for Visio

    As the title above can the Adapter Charger on?Creative MuVo2 FM be used for Creative?Vision M since both needs dc of 5V ? cause i have? charger for Creative muVo2 Fm but not ceati've Vision M. Thanks