Need of more than one synchronized methods

Inside my run method I'm calling a synchronized method which in turn calls other synchronized methods of the same and another class.
Now if the top level method is synchronized, does the need to make other methods synchronized still remain ?
Won't the other threads wait till the thread using the top level synchronized method returns.
Vik

Well, if you can be sure that the second method is not going to be called some other way except within that first synchronized method, then no it's not needed.

Similar Messages

  • More than one paint method?

    Hi
    Im wondering if it is possible to have more than one paint method. It should look something like this.
    public class MyApplet extends JApplet {
    public void paint(Graphics g) { // the normal paint method
    public void SecondPaint(Graphics gr) { // should i name the Graphics
    // to the same as in the normal paint method ( Graphics g) ?
    }And if its possible how would i repaint the other method?
    This is for the normal
    repaint(); and how would i do for the second paint method?
    please write an example program with two paint methods and just write below how to repaint.
    Thanks you som much if you reply

    (sorry to hijack this thread...) Yes, it'swindows,
    but right now my problem isn't even that. It'sjust
    catching and correcting basic c-coding errors.
    Witness my embarrassment in the JNI forum:
    http://forum.java.sun.com/thread.jspa?threadID=5213196
    &tstart=15
    Now if only I lived in "middle-of-no-where"Virginia!
    Nice! ;-)I saw your note about "middle-of-nowhere" Virginia a little too late. And you don't need to live here; my Solaris machine is up and running 24/7 and is open for SSH and XClient. (Also open for telnet, which comes built into windows, I believe.) If you'd like to brush up on Solaris C, C++ and Java development, just let me know. You're more than welcome to use the machine. I have tons of space on the drive and a dedicated connection just to that machine. There is an application for windows called CygwinX which is an XClient for Solaris. You can use that to remotely log into the Solaris desktop. There are about fifteen other people that I let use the machine for various reasons. I host myriad open source projects for development that you're more than welcome to mess around with. Tools available to you would be NetBeans 5.5, Sun Studio (with the Sun C/C++/Fortran compiler - which is beautiful by the way); and the whole suite of GNU compilers. I have the CDE and the JavaDesktop built in. I also have tons of Motif tutorials and demonstrations if you're interested in those. Heads up, though ... XServer tends to run pretty slowly when I have more than about four users logged onto a desktop at once. But like I said, if you (or just about anyone else for that matter) are interested, let me know and I'd be more than glad to set you up.

  • Can we have more than one service method in a single servlet

    can we have more than one service method in a single servlet?explain with example

    No, you can only have one service method. However, you can have it process two different requests as follows.
    Lets say you have two JSP pages. Put a hidden text value in one called jsp1 and a hiddent text value in the other called jsp2 (example: <input type="hidden" name="jspPage" value="jsp1"> and <input type="hidden" name="jspPage" value="jsp2">.
    Then in your service method, read in request.getParameter("jspPage") to determine if its jsp1 or jsp2 and call up the appropriate logic to process them separately.

  • Problem adding more than one point method in xmlrpc...

    Hello,
    I have an java program that connects to an webserver and communicates with an php file through xmlrpc. I have the need for more functions and so I need a little help here to have my server process each request:
    function Login($xmlrpcmsg)
    $result = "Hi from the server, " . "Username: " . $xmlrpcmsg->getParam(0)->scalarVal() . " Password: " . $xmlrpcmsg->getParam(1)->scalarVal();
    return new xmlrpcresp(new xmlrpcval($result, "string"));
    $s = new xmlrpc_server(array(
    "XmlRpcDemo.Login" => array(
    "function" => "Login",
    "signature" => $login_sig)
    basically i need $s to point to different methods. Like and register method for instance. Let me show you by code example:
    $s = new xmlrpc_server(array(
    "XmlRpcDemo.Login" => array(
    "function" => "Login",
    "signature" => $login_sig))
    "XmlRpcDemo.Register" => array(
    "function" => "Register",
    "signature" => $login_sig)));
    but that doesnt work you see? So how do I get this to work. Please help me!
    Much Appreciated,
    Aric Holland

    That code isn't Java. That is PHP.

  • How to add more than one paint method

    hi everyone
    I am doing a project in which i have already created a paint method but i find that there is necessity to create one more
    paint method within the same file in which i have a paint method pls tell me how to how to add a paint method how to call the repaint method
    please its very urgent

    By even suggesting that I can gather you have a horrible design of what ever you are doing--DON'T! And go back and refactor your application so you do not need or even want such a thing to happen.
    1 - paint is for use in AWT. If you are using AWT, then very well, you are at least using the right method to override. If you are using SWING, then you are totally messed up before you even arrived at this ill conceived plan of 2 paint methods.
    2 - your paint (AWT)/paintComponent (SWING) is a system called method driven by events you haven't any control over. You need to treat it as such.
    3 - your painting method should be very tight. I will bet your's is a horrid mess: overstuffed with attempted control and logic processes.
    4 - Even if you are using active rendering, your approach to 2 painting methods is horrible at best.
    If you need help in designing your process better, then post what you have and ask for help. IMO what you are doing can only lead to ugliness.

  • Can servlet has more than one init method...?

    Clarification 1:
    Suppose i will write init()(-without constructor) method. In this case, how servlet config object passed to init method.
    Clarification 2:
    if i will override init(ServletConfig) .why do i need to call super.init(config).
    thanks,
    JaiGaneshR

    suppose i ll override init method without constructor. //wrong
    i think u want.
    suppose i ll override init method without arguments
    then also servlet calls the init(ServletConfig) method.
    1st servlet container check in ur Servlet class for init(ServletConfig)
    it's not found.
    2.then it checks in the super class HttpServlet. it's not found.
    3.then it checks in the super class GenericServlet there it will found it.
    then it will execute.
    package javax.servlet;
    import java.io.IOException;
    import java.io.Serializable;
    import java.util.Enumeration;
    // Referenced classes of package javax.servlet:
    // Servlet, ServletConfig, ServletException, ServletContext,
    // ServletRequest, ServletResponse
    public abstract class GenericServlet
    implements Servlet, ServletConfig, Serializable
    public GenericServlet()
    public void destroy()
    public String getInitParameter(String name)
    return getServletConfig().getInitParameter(name);
    public Enumeration getInitParameterNames()
    return getServletConfig().getInitParameterNames();
    public ServletConfig getServletConfig()
    return config;
    public ServletContext getServletContext()
    return getServletConfig().getServletContext();
    public String getServletInfo()
    return "";
    public void init(ServletConfig config) *<-------------------------------------------------- called*
    throws ServletException
    this.config = config;
    init(); ---------------------------------------------------> called your override method
    public void init() *<------------------------------------------------- Not called*
    throws ServletException
    public void log(String msg)
    getServletContext().log(getServletName() + ": " + msg);
    public void log(String message, Throwable t)
    getServletContext().log(getServletName() + ": " + message, t);
    public abstract void service(ServletRequest servletrequest, ServletResponse servletresponse)
    throws ServletException, IOException;
    public String getServletName()
    return config.getServletName();
    private transient ServletConfig config;
    4. finally ur init() without arugments method will exected.
    Edited by: Lakshman.Balanagu on 26 Aug, 2008 3:43 PM
    Edited by: Lakshman.Balanagu on 26 Aug, 2008 3:44 PM

  • Creating more than one account for a single user

    I was wondering, if I creat more than one account for me (the only person that uses my powerbook) is that going overboard? I mean, lets say I am logged into the standard account and I want to learn more about the bash shell and using terminal which I am new to, if I **** something up will the whole system be toast or will only things in that account be messed up? Like could I then just log into my admin account and delete the other messed up one? Or no? My theory was that this was a way of keeping my comp safe from myself, being that I am new to macs and moreso that I am new to the unix side of things and want to start learning the command line without worrying about screwing up my whole system. I would just use the standard account for everyday use (like what I do now) or experiment with terminal, and when I need to download something or change some settings that requires me to be logged in as admin then I would log in and download what I need then log out and use it in the standard account...am I just wasting my time? Is what I am doing any "safer" than just having one admin account and thats it?
    Thanks for all the help! It feels good to be a part of the goodguys team =)
    Thanks again!

    Ghost,
    First, I don't subscribe to the "one should not use an admin account" philosophy. For someone who is the owner and main user of any given machine, I see the use of anything but an admin account a bit anal, totally unecessary, and needlessly complicating.
    On the other hand, I don't see the need for more than one admin account on any given machine. Yes, I see exceptions to this, and many people favor having a second admin account as a "backup," but I have never had more than one admin account on any of my machines, and have never encountered a situation where one would have helped.
    In short, I like the idea of having a "main" admin account that is used most of the time, and then having "secondary" accounts (all non-admin) for any additional users that might log in.
    Now, any limitations that apply to you as a GUI user of an account, admin or not, will apply to you at the command line as well. In other words, you can't get yourself into any more trouble at the command line than you can within the GUI. In fact, you might even be better protected at the command line than you are in the GUI. I say this because any action that would ordinarily "elevate" you above the standard capabilities of a non-admin user require the use of "sudo." Avoid the use of sudo, and you can avoid any problems.
    That doesn't mean that you wouldn't be able to do something stupid that might wreck an account that contains "all of your stuff," and on which you depend. It is not likely that you would damage your System, but it is entirely conceivable that you might, for example, accidently delete or overwrite your entire HOME folder. Oops!
    If you simply don't trust yourself with the command line, a second account might be a good place to experiment. Maybe create it as a non-admin account at first, with the option to change it to an admin account at a later time, when you want to learn how to use "sudo" to do more powerful things. By then, you will understand what not to do. Eventually, you will have the confidence to use the command line in your own account, which will have been an admin account all this while.
    Scott

  • Make more than one partion in my HHD

    hi
    i need make more than one partion in my HHD, i have A505 6033

    try this
    http://windows.microsoft.com/en-US/windows-vista/C​reate-and-format-a-hard-disk-partition

  • Configure more than one pop email

    Hello everybody, I need configure more than one POP email in Mail, somebody help me? Some manual to do this?
    Thanks

    Thanks for response, and other question, how make a second inbox for this other account? or all new message goes only to the inbox, don't care to which account is it?
    Thanks again

  • Building a method with more than one result data

    Hi, everyone:
    I'm a little shy to ask this question, however, it's been hanging in my mind for so long, so I think I'd rather make a confession on it. You may laugh at me if you want, I'm ready for that, but I more look forward to that someone can really give me the light, or even the link, or some hint....
    For your ease of reading, I give the question first, and my whole story behind:
    When I need a method which can provide more than one result( in other words, multiple outputs), how can I do it in Java? As I know, either you pass and object, or the result of the function is an object will do , for the object contains the datas you want, but that means your needs for those data have to be defined in object format in advance, won't that be inconvinient? Or Java has a better solution for that?
    //And here's the whole story....
    I began my career as a programmer by starting with LabVIEW, it's a graphical programming language made by National Instrument, and it's powerful on DAQ, and industrial field. One of the most important issues on design is to devide your system into multiple functions( in its own term: subVI), I think it's just like applying structured analysis method.
    When we dealing with functions in LabVIEW, a programmer can define his own function with mulitiple inputs and outputs, for example, I can design a function called SumAndDevide, which accepts two input ( two variables to be summed and devided) and gives two results( result of summing and that of deviding).
    The methodology has its power, at least it provide the functional decomposition, and you can compose a suitable solution in certain circumstance even they are not the smallest unit function. And testing is easy. It affects me so large that I look the trail of it when I come to other programming languages. In COBOL( well, that is a VERY old COBOL version ), I was scared to find there is no protection to the inner data on the performed sections, while making a outside subroutine to be called is cubersome and really a hard work. When I came to Delphi, I knew that using the result of a function cannot satisfy me, for it give only one output, even you can define it as variant, but I think it's vague to realize. So I use the difference of called by value and called by reference to handle the problem, that is: a value parameter for the input, and a variable paramter for the output.
    Well, when I came to Java, I am stunned again, now there is no passing by reference mechanism in Java, otherwise you have to pass it as an object, but that means when you need multiple outputs, the output has to be defined in object form in advance. And that will be very inconvinient!! I tried to find some solutions, but I can't. So is there any way that in Java you can define a method with multiple output? or Java handles the problem in totally different way?
    Any comments will be appreciated!!
    Thanks!!
    aQunx from Taiwan

    You missed the most common OO solution - separation of concerns and implementation hiding.
    If you have a function which returns a string, that is one method of the object that provides the service.
    If you have a function which returns a real, that is a different method of the object.
    If both functions require common code, move that into a private method which is called by both. If the method is costly, cache the result.
    eg an aerodynamics properties class, which could be done as a multivalued return of (lift, drag), refactored to independent lift() and drag() methods, which delegate to an interpolate() method, which caches the interpolated value and uses mach, pressureHeight and _alpha to determine whether it should recalculate:  /**
       * Calculates the aerodynamic drag force at a given mach, alpha and pressure height.
      public double drag (final double aMach, final double aPressureHeight, final double aAlpha) {
        interpolate(aMach, aPressureHeight, aAlpha);
        return _drag;
       * Calculates the aerodynamic lift force at a given mach, alpha and pressure height.
      public double lift (final double aMach, final double aPressureHeight, final double aAlpha) {
        interpolate(aMach, aPressureHeight, aAlpha);
        return _lift;
      private void interpolate (final double aMach, final double aPressureHeight, final double aAlpha) {
        if (aMach != _mach) {
          setMach(aMach);
          _pressureHeight = Double.NaN;
        if (aPressureHeight != _pressureHeight) {
          setPressureHeight(aPressureHeight);
          _alpha = Double.NaN;
        if (aAlpha != _alpha) {
          setAlpha(aAlpha);
    ... actual interpolation happens in the private setXXX methods.

  • Can a Method listen to more than one event in ABAP OO ?

    Hi,
    is it possible to prepare/register a handler method for e.g two events of two different classes ?
    Or can a method generally listen to only one event ?
    It seems that the syntax allows only one event ?
    methods event_handler for event my_event of my_class.
    Thanks for help in advance
    Olaf

    An event can refer to more than one object but you have to instantiate the objects
    for example   I have 2 grids and want to handle events depending on which grid
    the user is selecting / requesting actions on. (I've just posted the relevant bits coded here as data extraction etc you can code normally).
    FORM instantiate_grid
    * Create Grid container
    * Instantiate Grid class
    * Instantiate Event Handler class
    * Display the Grid
       USING  grid_container  TYPE REF TO cl_gui_custom_container
              class_object  TYPE REF TO cl_gui_alv_grid
              container_name TYPE scrfname.
    * create the container
      CREATE OBJECT grid_container
      EXPORTING container_name = container_name.
    * Create the ALV grid object using
    * container just created
      CREATE OBJECT  class_object
      EXPORTING
         i_parent = grid_container.
    *  Exclude the SUM function from the GRID toolbar
      ls_exclude = cl_gui_alv_grid=>mc_fc_sum.
      APPEND ls_exclude TO lt_exclude.
    * Instantiate our handler class
    * lcl_event_handler
      CALL METHOD class_object->register_edit_event
        EXPORTING
          i_event_id = cl_gui_alv_grid=>mc_evt_enter.
      CREATE OBJECT g_handler.
      SET HANDLER g_handler->handle_double_click FOR class_object.
      SET HANDLER g_handler->handle_hotspot_click FOR class_object.
      SET HANDLER g_handler->handle_toolbar FOR class_object.
      SET HANDLER g_handler->handle_user_command FOR class_object.
      SET HANDLER g_handler->handle_data_changed FOR class_object.
      SET HANDLER g_handler->handle_data_changed_finished FOR class_object.
    ENDFORM.                    "instantiate_grid
    MODULE status_0100 OUTPUT.
      IF grid_container IS INITIAL.
        PERFORM instantiate_grid
           USING grid_container
                 grid1
                 'CCONTAINER1'.
    * Grid title Primary Grid
        struct_grid_lset-grid_title = 'Delimit Old org Units - Selection'.
        struct_grid_lset-edit =  'X'.
        struct_grid_lset-sel_mode = 'D'.
        PERFORM display_grid
         USING
            grid1
             <dyn_table>
             it_fldcat.
      ENDIF.
      SET PF-STATUS '001'.
      SET TITLEBAR '000' WITH 'Delimit Old Org Units'.
    ENDMODULE.                    "status_0100 OUTPUT
    * PAI module
    MODULE user_command_0100 INPUT.
      CASE sy-ucomm.
        WHEN 'BACK'.
          LEAVE PROGRAM.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
        WHEN 'CANC'.
          LEAVE PROGRAM.
        WHEN 'RETURN'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                    "user_command_0100 INPUT
    MODULE status_0200 OUTPUT.
      IF grid_container1 IS INITIAL.
        PERFORM instantiate_grid
           USING grid_container1
                 grid2
                 'CCONTAINER2'.
    * Grid title  secondary grid
        struct_grid_lset-grid_title = 'Delimited Objects'.
        struct_grid_lset-edit =  ' '.
        PERFORM display_grid
         USING
            grid2
             <dyn_table1>
             it_fldcat1.
      SET PF-STATUS '001'.
      SET TITLEBAR '000' WITH 'Org Units Delimited'.
    endif.
    ENDMODULE.                    "status_0200 OUTPUT
    In your local event handling class use the variable SENDER to  determine which grid / object triggered the event
    for example
    CLASS lcl_event_handler DEFINITION .
      PUBLIC SECTION .
        METHODS:
    **Hot spot Handler
        handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
                          IMPORTING e_row_id e_column_id es_row_no,
    **Double Click Handler
        handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
                                        IMPORTING e_row e_column es_row_no
                                        sender,
    ** Toolbar handler.
    handle_toolbar
            FOR EVENT toolbar OF cl_gui_alv_grid
                IMPORTING e_object e_interactive
                sender,
    * button press
        handle_user_command
            FOR EVENT user_command OF cl_gui_alv_grid
                IMPORTING e_ucomm
                 sender,
    * data changed
    handle_data_changed
        FOR EVENT data_changed OF cl_gui_alv_grid
          IMPORTING er_data_changed,
    *data changed finished
    handle_data_changed_finished
         FOR EVENT data_changed OF cl_gui_alv_grid,
    download_to_excel.
    ENDCLASS.                    "lcl_event_handler DEFINITION
    * Implementation methods for lcl_event_handler
    CLASS lcl_event_handler IMPLEMENTATION.
    *Handle Hotspot Click
    * When a "hotspotted"cell is double clicked
    * Hotspot indicatore needs to be set in
    * the field catalog.
    * Not required for this application.
      METHOD handle_hotspot_click .
        PERFORM mouse_click
          USING e_row_id
                e_column_id.
        CALL METHOD grid1->get_current_cell
          IMPORTING
            e_row     = ls_row
            e_value   = ls_value
            e_col     = ls_col
            es_row_id = ls_row_id
            es_col_id = ls_col_id
            es_row_no = es_row_no.
        CALL METHOD grid1->refresh_table_display.
        CALL METHOD grid1->set_current_cell_via_id
          EXPORTING
            is_column_id = e_column_id
            is_row_no    = es_row_no.
      ENDMETHOD.                    "lcl_event_handler
    *Handle Double Click
      METHOD  handle_double_click.
        CASE sender.
          WHEN grid1.
    * returns cell double clicked  FROM GRID 1
    * Ignore any event from GRID 2
            PERFORM double_click
               USING e_row
               e_column.
        ENDCASE.
      ENDMETHOD.                    "handle_double_click
    * Add our buttons to standard toolbar
      METHOD handle_toolbar.
        CASE sender.
    * Only add functionality to PRIMARY GRID (GRID 1)
          WHEN grid1.
    * append a separator to normal toolbar
            CLEAR ls_toolbar.
            MOVE 3 TO ls_toolbar-butn_type.
            APPEND ls_toolbar TO e_object->mt_toolbar.
    * Delimit Org
            CLEAR ls_toolbar.
            MOVE 'PROC' TO ls_toolbar-function.
            MOVE icon_railway TO ls_toolbar-icon.
            MOVE 'DELIMIT' TO ls_toolbar-quickinfo.
            MOVE 'DELIMIT ORG UNIT' TO ls_toolbar-text.
            MOVE ' ' TO ls_toolbar-disabled.
            APPEND ls_toolbar TO e_object->mt_toolbar.
    * Select All Rows
            MOVE 'SELE' TO ls_toolbar-function.
            MOVE icon_select_all TO ls_toolbar-icon.
            MOVE 'ALL CELLS' TO ls_toolbar-quickinfo.
            MOVE 'ALL CELLS' TO ls_toolbar-text.
            MOVE ' ' TO ls_toolbar-disabled.
            APPEND ls_toolbar TO e_object->mt_toolbar.
    * Deselect all Rows.
            MOVE 'DSEL' TO ls_toolbar-function.
            MOVE icon_deselect_all TO ls_toolbar-icon.
            MOVE 'DESELECT ALL' TO ls_toolbar-quickinfo.
            MOVE 'DESELECT ALL' TO ls_toolbar-text.
            MOVE ' ' TO ls_toolbar-disabled.
            APPEND ls_toolbar TO e_object->mt_toolbar.
            ENDCASE.
         move  0 to ls_toolbar-butn_type.
         move 'EXCEL' to ls_toolbar-function.
         move  space to ls_toolbar-disabled.
         move  icon_xxl to ls_toolbar-icon.
         move 'Excel' to ls_toolbar-quickinfo.
         move  'EXCEL' to ls_toolbar-text.
         append ls_toolbar to e_object->mt_toolbar.
      ENDMETHOD.                    "handle_toolbar
      METHOD handle_user_command.
    * Entered when a user presses a Grid toolbar
    * standard toolbar functions processed
    * normally
       g_sender = sender.
        CASE e_ucomm.
          WHEN 'PROC'.    "Process selected data
            PERFORM get_selected_rows.
          WHEN 'SELE'.
            PERFORM select_all_rows.
          WHEN 'DSEL'.
            PERFORM deselect_all_rows.
          WHEN 'EXCEL'.
              call method me->download_to_excel.
            WHEN OTHERS.
        ENDCASE.
      ENDMETHOD.                    "handle_user_command
      METHOD handle_data_changed.
    * only entered on data change  Not req for ths app.
        PERFORM data_changed USING er_data_changed.
      ENDMETHOD.                    "data_changed
      METHOD handle_data_changed_finished.
    * only entered on data change finished  Not req for ths app.
        PERFORM data_changed_finished.
      ENDMETHOD.                    "data_changed_finished
    * Interactive download to excel
      method download_to_excel.
      field-symbols:
       <qs0>   type standard table,
       <qs1>   type standard table.
      data: G_OUTTAB1 type ref to data,
            g_fldcat1 type ref to data,
            LS_LAYOUT type KKBLO_LAYOUT,
            LT_FIELDCAT type KKBLO_T_FIELDCAT,
            LT_FIELDCAT_WA type KKBLO_FIELDCAT,
            L_TABNAME type SLIS_TABNAME.
    case g_sender.
      when grid1.
         get reference of <dyn_table> into g_outtab1.
         get reference of it_fldcat into g_fldcat1.
       when grid2.
       get reference of <dyn_table1> into g_outtab1.
         get reference of it_fldcat1 into g_fldcat1.
    endcase.
       assign g_outtab1->* to <qs0>.
        assign g_fldcat1->* to <qs1>.
           call function  'LVC_TRANSFER_TO_KKBLO'
          exporting
            it_fieldcat_lvc   = <qs1>
    *     is_layout_lvc     = m_cl_variant->ms_layout
             is_tech_complete  = ' '
          importing
            es_layout_kkblo   = ls_layout
            et_fieldcat_kkblo = lt_fieldcat.
        loop at lt_fieldcat into lt_fieldcat_wa.
          clear lt_fieldcat_wa-tech_complete.
          if lt_fieldcat_wa-tabname is initial.
            lt_fieldcat_wa-tabname = '1'.
            modify lt_fieldcat from lt_fieldcat_wa.
          endif.
          l_tabname = lt_fieldcat_wa-tabname.
        endloop.
        call function 'ALV_XXL_CALL'
             exporting
                  i_tabname           = l_tabname
                  is_layout           = ls_layout
                  it_fieldcat         = lt_fieldcat
                  i_title             = sy-title
             tables
                  it_outtab           = <qs0>
             exceptions
                  fatal_error         = 1
                  no_display_possible = 2
                  others              = 3.
        if  sy-subrc <> 0.
          message id sy-msgid type 'S' number sy-msgno
                 with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        endif.
    endmethod.
    ENDCLASS.                    "lcl_event_handler IMPLEMENTATION
    The sender instance is a variable such as  g_sender type ref to cl_gui_alv_grid.       "Sender instance.
    The above example is for OO ALV grids but should work for other interactive cases where a User presses a key or does a mouse action.
    Cheers
    jimbo

  • Methods that return more than one object.

    Hello everyone,
    I don't know if this has ever been proposed or if there's an actual solution to this in any programming language. I just think it would be very interesting and would like to see it someday.
    This is the thing: why isn't it possible for a method to return more than one object. They can receive as many parameters as wanted (I don't know if there's a limit), but they can return only 1 object. So, if you need to return more than one, you have to use an auxiliary class...
    public class Person {
       private String name;
       private String lastName;
       public Person(String name, String lastName) {
          this.name = name;
          this.lastName= lastName;
       public String getName() {
           return name;
       public String getLastName() {
           return lastName;
    }So if you want to get the name of somebody you have to do this, assuming "person" is an instance of the object Person:
    String name = person.getName();And you need a whole new method (getLastName) for getting the person's last name:
    String lastName = person.getLastName();Anyway, what if we were able to have just one method that would return both. My idea is as follows:
    public class Person {
       private String name;
       private String lastName;
       public Person(String name, String lastName) {
          this.name = name;
          this.lastName= lastName;
       public String name, String lastName getName() {
           return this.name as name;
           return this.lastName as lastName;
    }And you would be able to do something like:
    String name = person.getName().name;and for the last name you would use the same method:
    String lastName = person.getName().lastName;It may not seem like a big deal in this example, but as things get more complicated simplicity becomes very useful.
    Imagine for example that you were trying to get information from a database with a very complex query. If you only need to return 1 column you have no problem, since your object can be an array of Strings (or whatever type is necessary). But if you need to retrieve all columns, you have three options:
    - Create 1 method per column --> Not so good idea since you're duplicating code (the query).
    - Create and auxiliary object to store the information --> Maybe you won't ever use that class again. So, too much code.
    - Concatenate the results and then parse them where you get them. --> Too much work.
    What do you think of my idea? Very simple, very straight-forward.
    I think it should be native to the language and Java seems like a great option to implement it in the future.
    Please leave your comments.
    Juan Carlos García Naranjo

    It's pretty simple. In OO, a method should do one thing. If that thing is to produce an object that contains multiple values as part of its state, and that object makes sense as an entity in its own right in the problem domain--as opposed to just being a way to wrap up multiple values that the programmer finds it convenient to return together--then great, define the class as such and return an instance. But if you're returning multiple values that have nothing to do with each other outside of the fact that it's convenient to return them together, then your method is probably doing too much and should be refactored.
    As for the "if it increases productivity, why not add it?" argument, there are lots of things that would "increase productivity" or have some benefit or other, but it's not worth having them in the language because the value they add is so small as to no be worth the increase in complexity, risk, etc. MI of implementation is one great example of something that a lot of people want because it's convenient, but that has real, valid utility only in very rare cases. This feature is another one--at least in the domain that Java is targetting, AFAICT.

  • I need to connect my iPad to a projector and USB ports. What do I need to do this and where can I get the suitable fittings? I really need to have more than one USB connection port. Help

    I need to connect my iPad to a projector and have USB ports. What do I need to do this and where can I get the suitable fittings? I really need to have more than one USB connection port. Help

    You can connect via a cable or wireless using an Apple TV.
    http://ipad.about.com/od/iPad_Guide/a/How-To-Connect-Your-Ipad-To-Your-Tv.htm
    Connect an iPad to a Television or Projector
    http://www.everymac.com/systems/apple/ipad/ipad-faq/how-to-connect-ipad-to-tv-te levision-projector.html
    Connecting iPad iPhone or iPod to TV or Projector
    http://www.disabled-world.com/assistivedevices/computer/ipad-tv.php
    iPad Accessories: Connections for a TV or Projector
    http://www.dummies.com/how-to/content/ipad-accessories-connections-for-a-tv-or-p rojector.html
    You may be interested in AirPlay on the Apple TV:
    http://www.apple.com/airplay/
    Alternately, there are Apple Digital AV Adapters for hardwired connections:
    http://support.apple.com/kb/ht4108
    If your location does’t have wifi to use with the Apple TV, use a portable router.
    Portable routers http://compnetworking.about.com/od/routers/tp/travel_routers.htm
     Cheers, Tom

  • I have more than one apple id and need to coordinate them

    I have more than one Apple ID and cant coordinate them over my devices

    That's correct. They cannot be merged nor terminated. You can stop using them. Note that anything you purchased (free or paid) is permanently connected with the Apple ID used to purchase those items. Only Apple has the ability to make those changes, so you would need to ask them for help.
    Apple Store Customer Service at 1-800-676-2775 or visit online Help for more information.
    To contact product and tech support: Contacting Apple for support and service - this includes
    international calling numbers..
    For Mac App Store: Apple - Support - Mac App Store.
    For iTunes: Apple - Support - iTunes.

  • HT1206 I have a computer with 2 users and each of us have I tunes authorized but only one of us can cloud sync our purchases what can I do I need more than one ID available

    Help please I need to have more than one Itunes Id

    Well you need to understand the behavior of h-reap or what it's called now, FlexConnect. In this mode, the clients are still remembers on the WLC until the session timer/idle timer expires. So switching between SSID's in h-reap will not be the same when switching when the AP's are in local mode.
    Take a look at the client when connected in FlexConnect in the WLC GUI monitor tab. Thus will show you what ssid and vlan the client is on. Now switch to a different ssid and compare this. It's probably the same because the client has not timed out. Now go back to the other ssid and look again. Now on the WLC, remove or delete the client and then switch to the other ssid at the same time. Or switch SSID's and then remove the client. The client will join the new ssid and in the monitor tab, you should see the info.
    There is no need to have clients have multiple SSID's unless your testing. Devices should only have one ssid profile configured to eliminate any connectivity issues from the device wanting to switch SSID's.
    Sent from Cisco Technical Support iPhone App

Maybe you are looking for

  • How to show Open Sales Orders only in a report?

    Hi, I am working on a Business Objects report to show open sales orders. Here i pull data from a RapidMart universe for which data comes from SAP. I just wanted to know which object or field in SAP can/will differentiate whether a particular sales or

  • Issue with display data from infoset

    Dear Experts, When I am trying to display data from BI INFOSET in (Execute in background ctrl+F2)backend it is working fine but when in try to run the execution in forground (execute F8) then the system gets hang.. and time out. could any one has thi

  • Re-installing mac os x

    hi i am new to mac and i have just bought a macbook pro and a macbook. i am giving my macbook pro to my brother however it still has all my stuff on it. how can i get the computer back to the way i first got it. do i just put in the install disks and

  • New Macbook, I think I am in love...

    Last week I broke down and did it, I walked to my friendly campus computer store and wrote a check for a new Macbook. I got a Black 2.0 and I have never been happier in my entire life. All of my Windows friends were telling me that I was going to reg

  • Deleting System Call Handlers in Unity 7.x

    I am trying to delete a system call handler for a conference room extension we have.  When I try and delete it I get an error message  "Operation cannot be completed because the object is in use"  How can I find out what its linked to so I can remove