Wat is the use of having a synchronized block

instead of a synchronized????....Can anyone explain??...Is it because we can do the synchronization altogether for all the functions?//
is this the only use of it??
pls explain........

You synchronize on an object, not a set of methods. If you write:
public synchronized void f() {
// code here
}Then that's shorthand for:
public void f() {
   synchronized(this) {
     // code here
}But you don't always want to synchronize for the whole of a method, and you don't always want to synchronize on this.
The Object you synchronize on is called a monitor, and it's that object that can't simultaneously be synchronized on by more than one threads.

Similar Messages

  • Wat is the use of casting in field symbols

    wat is the use of casting in field symbols?

    When you assign a data object to a field symbol, you can cast to any data type. This means that any area of memory can be viewed as having assumed a given type. You can then address parts of fields symbolically without having to use offset/length addressing.
    A cast is performed using the CASTINGaddition of the ASSIGN statement. The CASTINGaddition allows you to assign a data object to a field symbol where the type of the data object is incompatible with that of the field symbol. There are two types of casting: casting with an implicit type declaration and casting with an explicit type declaration.
    For details please have a look at below link:
    [Casting|http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3930358411d1829f0000e829fbfe/frameset.htm]
    I hope it helps.
    Thanks,
    Vibha
    Please mark all the useful answers

  • Whats the use of having pragma autonomous transaction

    Hii All,
    The below is the procedure developed by our predecessors.We are making use of this for writing our debug messages.
    I'm aware of pragma autonomous transaction ,this allows my code to run independently of the calling program.
    But here we are just using utl_File and we are neither using any DML(Inserting error messages into a table) or DDL statements in the below code.
    What is real use of having pragma autonomous transaction.???This code is working in the same way even without the pragma...I dont' find any difference .
    Please let me know the use of having pragma autonomous transaction in the below procedure and where it actually comes into usage.
    Create or replace Procedure logmesg
    p_file_name          in          varchar2,
    p_mesg_text          in          varchar2,
    p_dir_path          in          varchar2 default fn_get_debug_path,
    p_file_ext          in          varchar2 default 'log',
    p_append_flag     in          varchar2 default 'Y'
    ) Is
              pragma autonomous_transaction;
              l_utl_file                    utl_file.file_type;
              l_append_flag               varchar2(1);
              l_mesg_text                    varchar2(32000);
              l_file_name                    varchar2(3000);
              l_dir_path                    varchar2(32000);
              l_delimeter_occurance     number;
              l_buffer_str               varchar2(32000);
    Begin
              if trim(p_dir_path) is null then
                   l_dir_path     := fn_get_debug_path ;
              else
                   l_dir_path := p_dir_path;
              end if;
              l_mesg_text := p_mesg_text;
              l_append_flag := nvl(p_append_flag,'Y');
              l_file_name     := p_file_name||'_'||to_char(sysdate,'ddmmyyyyhh')||'.'||p_file_ext;
              l_append_flag := Case     l_append_flag
                                       When 'Y' then 'a'
                                       When 'N' then 'w'
                                   End;--l_append_flag
              Begin
                   l_utl_file := utl_file.fopen(l_dir_path,l_file_name,l_append_flag);
              Exception
                   When Others Then
                        l_utl_file := utl_file.fopen(l_dir_path,l_file_name,'w');
              End;
              if dbms_lob.getlength(l_mesg_text) > 32000 then
                   loop
                        exit when dbms_lob.getlength(l_mesg_text) < 32000;
                        l_delimeter_occurance := dbms_lob.instr(l_mesg_text,chr(32),1,1);
                        l_buffer_str := dbms_lob.substr(l_mesg_text,l_delimeter_occurance-1);
                        utl_file.put_line(l_utl_file,l_buffer_str);
                        l_mesg_text := dbms_lob.substr(l_mesg_text,l_delimeter_occurance+1);
                        utl_file.fflush(l_utl_file);
                   end loop;
              end if;
              utl_file.put_line(l_utl_file,l_mesg_text);
              utl_file.fflush(l_utl_file);
              utl_file.fclose(l_utl_file);
    End logmesg;
    /Here

    Please let me know the use of having pragma autonomous transaction in the below procedure and where it actually comes into usage.Seems it is redundant in that procedure, and doesn't add any value, since the procedure isn't doing anything 'transactional'.
    I would remove it.

  • Wat is the use of occurs

    hi all
    wat is the use of occurs while declaring internal table.
    thankn in advance

    Hi
    The OCCURs Clause is used for declaring the SIZE of the Internal Table..
    For EG:
    Data: begin of itab occurs 0, means this will create an internal table with 8KB of memory.
    But if you are specifrying
    data:begin of itab occurs 10, this will create an internal table with 10 rows(according to the structure of the internal table)...
    Reward All Helpfull Answers........

  • Wat is the use of sid in extended star schema rather than linking masterdat

    hi bw gurus,
    wat is the use of sid in extended star schema rather than linking masterdata with dimention tables?
    thanx in advace,
    i will assign points,
    srinivas

    hi,
        the sid are used instead of the data in order to avoid the redunduncy of data.
    and reduce the datastorage size.
    the data will be present in the sid table and the data is linked used the corerponding sid in the dimension.
    regards

  • Help required understanding the purpose of having instance Init blocks

    I want to know exactly what the purpose of having instance initialization blocks in Java. As in static init blocks, we can execute some commands before creating an instance of a class.
    And also in instance init blocks, we are executing some commands which we can do in a constructor. So I’m little bit confused of the purpose of having this concept instance init blocks without writing it in the constructor itself.
    Really appreciate if anyone can explain this ASAP as I am still a beginner who is studying for SCJP exam.
    Thanks in advance.

    The instance initialization blocks are always executed before the constructor code is executed. This may be used for some activity which is common to all constructors (in case constructors are overloaded).

  • Wat is the use of ports those are used for EMconsole

    hi all;,
    Could anyone please tell me
    1. the use of the agent,rmi and jms ports used for the dbconsole?
    2. if i block those ports can i use dbconsole?
    3. what are all the ports used for the database like listener, dbconsole http, dbconsole agent etc. and use of those.
    Thanks & Regards,
    Sagar Maram

    What is the use of the rmi and jms ports i mean how those are getting used internally. if block those ports with firewal then wat happend to dbconsole.?They are more appserver related components and to be clear..if the apps and DB are in the same server...then if you block these ports your DBConsole/Appconsole continues to work as long you have not blocked http DBconsole/Appconsole ports...
    But if you apps and DB are across network with a firewall between them then there is a possibility some of the functionality might not work but http console should work as long as http console port is opened in the firewall.....

  • Wat is the use of Advance tab in obiee

    hi all ,
    What is the use of advance tab , and that xml thing ..
    can any one tel me about it
    Thanks

    791907 wrote:
    hi all ,
    What is the use of advance tab , and that xml thing ..
    can any one tel me about it
    ThanksIf you actually go into the Advanced tab you will find some meaningful descriptions against everything on it.
    'That XML Thing' , its the definition of your report, criteria panel, views on the results tab.

  • What is the use of having process profiles in SPP?

    Dear all,
    what is the use of process profile in spp? it says we use it for specifying packaging methods and packaging sizes, but what are they used for?
    can someone throw some light on it please?
    regards,
    binod

    Hi Binod,
    You define a process profile in Customizing for SCM Basis under Planning Service Manager ® Define Process Profile. A process profile includes a method for package creation and the maximum number of planning objects that a package can contain.
    This is one of the steps in creating a Planning Service Manager Jobs.
    If you setup a PSM job and run it then you get a clear idea.
    Please have a look at the below link:-
    http://help.sap.com/saphelp_scm2007/helpdata/en/42/cc2978ebc16bb1e10000000a1553f6/frameset.htm
    Thanks,
    KD

  • The use of this in synchronizing.....

    My book is giving too much of a vague explanation and here is a snippet that I have a few questions on...
    public class TestIt{public void doThings(){
    synchronized(this){
    //do synchronized stuff
    }Now the question I pose is that the book is giving an explanation that the method and only the method that the synchronized block is a member of is now synchronised. However it also says that the "this" keyword refers to the object running(which I know) but correct me if I am wrong methods are not objects? I am getting a mixed message and need help please.....
    Is it only the method(doThings) or both the class and method that become synchronized?

    Every object in Java has a lock associated with it. It's not something you can refer to directly in your code.
    Whenever you enter a synchronized block or method, you obtain an object's lock. When you leave that block or method, or call wait(), you release that lock, and some other thread can acquire it.
    When you do synchronized (x), you are obtaining the lock associated with the object that reference x points to. So when you do synchronized (this), you're obtaining the lock for the current object.
    We don't synchronize objects. We synchronize blocks or methods on objects (or on the objects' locks).
    Declaring a method synchronized is shorthand for what you could do by explicitly syncing a block of code on a particular object.*
    class Foo {
      synchronized void bar() {
        // body
      // is the same as
      void bar() {
        synchronized (this) {
          // body
      // and
      static synchronized qux() {
        // body
      // is the same as
      static qux() {
        synchronized (Foo.class) {
          // body
    }In all cases, you're just syncing on an object, and which object doesn't matter, except to other methods or blocks that sync on the same object. Everything else is identical, "as far as the behavior of the threads is concerned".

  • Wat is the use of "DATA var-name LIKE SY-INDEX" statement

    Hi to all,
           is there any use of "DATA <var-name> LIKE SY-INDEX"  statement in ABAP, do the variable <var-name> be changed with that of SY-INDEX when we declare like this.
             Could u give me a fast response,
                                            Thank you,
                                                 Srinivasa Rao k.

    hi check this example..
    data: v_index type sy-index value 10 .
    do 15 times .
    if sy-index = v_index .
    write:/ 'the system index is 10 '.
    exit.
    endif.
    enddo.
    the main use of the index is used in the hr programs..
    the user wants the emp salary and previous months   salary then you need to use the index .
    if the table had 10 records .then you need to catch the record of  index1(current) and index 2(for previous month)..
    select pernr ansal  from pa0008 into table it_pa0008 where pernr in s_pernr and begda in s_begda .
    loop at it_pa0008.
    case sytabix.
    when 1 .
    it_final-cursal =  it_pa0008-ansal.
    when 2 .
    it_final-prevsal =  it_pa0008-ansal.
    endcase .
    endloop.
    regards,
    venkat.

  • I chose a theme and would like my home page to be a blank tab, but show the theme with icons on it instead of a white page. What is the use of having a cool theme if you never see it. Is this a posibility?

    I chose the theme purple moon. I was hoping that the home page could be set up customized with icons of my most used websites and tool icons where you can see the theme, but the only think I can set it to is a blank white page.

    I have now recently downloaded 10.0.2 which is confusing in itself, as, as far as I can ascertain that is actually version 11, but I'm not even sure about that.
    Version 10.0.2 is the newest version and the successor to GarageBand '11 (version 6.0.5).
    The '11 is referring to the iLife '11 suit of multimedia application - the older GarageBand was a part of this bundle.
    Have a look at Edgar's graphical enhanced manuals, the explain very detailed how things work and why. You can buy them as iBooks from the iBook store or directly from the page:
    http://DingDingMusic.com/Manuals/

  • Wat is the use of writting

    "break-point" at the start of the program.

    Hi,
    A breakpoint is the signal, which is specified in the program, tells the system to stop the program execution and to start the debugger
    Static are set up with the BREAKPOINT keyword inside the program, which you can directly display with the ABAP/4 source code editor.  To set the breakpoint in the program enters the keyboard BREAKPOINT.
    The ABAP/4 debugger is the development workbench tool, which allows you to stop a program during its execution when a particular condition is met.  When the program is stopped, you can use the debugger to display the contents of the table and variable being used by the program.  It allows you to execute the program step by step, reviewing exactly the real flow of the program execution.
    Regards,
    Sruthi

  • Wat is the use of sy-cucol and how to use tel me the syntax

    pls let me know

    Hi,
    SY-CUCOL: Position of the column in the window from which the event was triggered (counting starts with 2) i.e Horizontal cursor position.
    Ex.
    REPORT demo_list_system_fields NO STANDARD PAGE HEADING
    LINE-COUNT 12 LINE-SIZE 40.
    DATA: l TYPE i, t(1) TYPE c.
    DO 100 TIMES.
    WRITE: / 'Loop Pass:', sy-index.
    ENDDO.
    TOP-OF-PAGE.
    WRITE: 'Basic List, Page', sy-pagno.
    ULINE.
    TOP-OF-PAGE DURING LINE-SELECTION.
    WRITE 'Secondary List'.
    ULINE.
    AT LINE-SELECTION.
    DESCRIBE FIELD sy-lisel LENGTH l TYPE t.
    WRITE: 'SY-LSIND:', sy-lsind,
    / 'SY-LISTI:', sy-listi,
    / 'SY-LILLI:', sy-lilli,
    / 'SY-CUROW:', sy-curow,
    / 'SY-CUCOL:', sy-cucol,
    / 'SY-CPAGE:', sy-cpage,
    / 'SY-STARO:', sy-staro,
    / 'SY-LISEL:', 'Length =', l, 'Type =', t,
    / sy-lisel.
    This program creates a list of ten pages. When you run the program, you can place the cursor within the basic list and create a detail list by choosing Choose. This displays the contents of the system fields.
    SY-LSIND is the index of the current list, SY-LISTI is the index of the previous list.
    SY-LILLI is the number of the selected line in the list, SY-CUROW contains the line number of the selected line on the current screen. SY-CUCOL is the position of the cursor in the window. This position exceeds the corresponding unscrolled list column by one. SY-CPAGE is the currently displayed page of the list. SY-STARO is the number of the topmost actual list line displayed on the current page. This does not include the page header. SY-CPAGE and SY-STARO do not depend on the cursor position. For SY-LISEL, the program displays length, data type, and contents. The length of SY-LISEL is always 255, independent of the list's width.
    Regards,
    Bhaskar

  • What is the use of the setter dependency injection in Spring?

    What is the use of the dependency setter injection ?
    In a database driven app, I retrieve results, use the javabeans set methods to save stuff in javabeans and then call get on it.
    What is the use of having something set externally from a xml already ?
    Can someone provide an example when the setter injection can be used?
    I wouldnt imaginge using it to get usernames, passwords, databaseurl because we use JNDI for that...
    Is the dependency setter meant as something additional to web.xml so you dont have to get params from web.xml?

    No, you would indicate in the XML that the Hibernate object and the TransactionFactory (I am being vague here) have a dependency. You then specify whether you want setter or constructor injection. When Spring creates the Hibernate Object, it will attempt to also create a TransactionFactory and pass that to the Hibernate Object's setter. "Auto-wiring" them together for you.
    - Saish

Maybe you are looking for

  • What is PDK & how to use it in NWDS 7.0.07

    Hi All, I was using NWDS for webdynpro development for a pretty long time. I am working on some portal development and came across PDK. What is PDK and its usage with Portal application development. if its a plugin where to down load it and how to us

  • Question on Using Persistence Object

    Hi, I want to store a hashtable of persistent info with about five attributes (id, name, username, date) in order to not always call the database. I am either going to use session or request objects. My question is if it's a good idea to store the ha

  • Problem in Cluster Table Maintenance in sm34

    Dear ABAP Experts, I am new to abap. I am struck in a problem. I have created a View Clusters to maintain database tables. (in se54) But when I go and try to maintain the fields of database tables: In "new entries" I am able to add only one fild and

  • Clicking on a link opens a broken window that never completes?

    When clicking on some links (for example, a list of links to pages in a newsletter email), a few will open, then I get dead windows. Sometimes the window will have just a title in the top bar and not go any further. More recently, I've been getting t

  • Media offline / file import failure

    Hi, I have my project created in Premiere CS6. Now i updated to CC. In my project, i imported a really short AE file into my Pr timeline. The whole vidieo worked fine. Now I just noticed that media (AE file) was reported media offline in Premiere CC.