Is volatile necessary for variables only accessed inside synchronized block

Hi,
I am using ExecutorService to execute a set of threads. Then the calling thread needs to wait until all of them are done to reuse the thread pool to run another set of threads (so I can't use the ExecutorService.shutdown() to wait for all of the threads at this point). So I write a simple monitor as below to coordinate the threads.
My question is: will it work? someone suggests that it might not work because it will busy spin on the non-volatile int which may or may not be updated with the current value from another thread depending on the whims of the JVM. But I believe that variables accessed inside synchronized blocks should always be current. Can anyone please help me to clarify this? Really appreciate it.
     * Simple synchronization class to allow a thread to wait until a set of threads are done.
     class ThreadCoordinator{
     private int totalActive = 0;
     public synchronized void increment(){
     totalActive++;
     notifyAll();
     public synchronized void decrement(){
     totalActive--;
     notifyAll();
     public synchronized void waitForAll(){
     while(totalActive != 0){
     try{
     wait();
     }catch (InterruptedException e){
     //ignore
     }

Don't do that. Just save the Futures returned by the ExecutorService, and call get() on them all. This will only return when all the tasks have finished.

Similar Messages

  • [svn:bz-trunk] 21661: Avoid calling throwNotSubscribedException() from inside synchronized blocks to prevent potential issues acquiring the lock .

    Revision: 21661
    Revision: 21661
    Author:   [email protected]
    Date:     2011-07-21 06:21:07 -0700 (Thu, 21 Jul 2011)
    Log Message:
    Avoid calling throwNotSubscribedException() from inside synchronized blocks to prevent potential issues acquiring the lock.
    Checkin-Tests: Pass
    QA: Yes
    Doc: No
    Modified Paths:
        blazeds/trunk/modules/core/src/flex/messaging/client/FlexClient.java

  • Database open for read-only access ORACLE

    while building a universe with a dblink betweens oracle databases, i try to create a derived table in the form
    select field1 from table@db_to_db2
    but i get the following message:
    Exception: DBD, ORA-16000: database open for read-only acces State N/A.
    I understand the statement "Set Transaction for read only"  must be set before any transaction during the session, but still dont know how to trigger it in bo universe designer.
    Can someone know how to solve it?

    I suggest you fill-in the BEGIN_SQL parameter on the Universe to turn on the read-only transaction.
    Here is an excerpt from the Universe Designer guide:
    The BEGIN_SQL parameter allows you to prefix SQL statements with the same parameters each time a SQL statement is generated.
    1. Open the "Universe Parameters" dialog box in Designer.
    2. Click the Parameter tab.
    3. In the "Parameter" list, select the BEGIN_SQL parameter and enter the
    appropriate prefix commands.
    4. Save the settings.
    5. Save the universe.

  • How do I save excel file with password for read only access ?

    Hi
    I am trying to save an excel file with a password to make it read only when opened
    using OLE2 . I am having a problem with the parameter list. This is my code that does
    work.
    args := OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(args, 'C:\Reports\Excel\File.xls');
    ole2.add_arg(args, 0);
    ole2.add_arg(args, 0);
    ole2.add_arg(args, 'TEST');
    ole2.add_arg(args, 0);
    ole2.add_arg(args, 0);
    ole2.add_arg(args, 1);
    I also have the following code at the beginning of the program to suppress dialogs.
         OLE2.SET_PROPERTY(application,'DisplayAlerts', 'FALSE');
         ole2.set_property(application,'Visible', 'false');

    Hope it help.
         -- Begin : Protect your worksheet
         args := OLE2.CREATE_ARGLIST;
         OLE2.ADD_ARG(args,yourpassword); -- choose your password
         OLE2.INVOKE(worksheet, 'Protect', args);
         OLE2.DESTROY_ARGLIST(args);
         -- End : Protect your worksheet
         -- Begin : Save and close worksheet
         OLE2.INVOKE(workbook, 'Save');
         OLE2.INVOKE(workbook, 'Close');
         -- END : Save and close worksheet

  • What is the best solution for Internet patter access inside of domain BizTalk server?

    Hi guys,
    Our BizTalk server put the company domain network, it can't access to the internet, just external DMZ can be access from internet.
    senario:
    Internet partner <=> Extenal DMZ server <=> intenal DMZ server <=> BizTalk Server
    1.Internet partner and external DMZ Server can access each other 
    2.external and internal DMZ Server can access each other
    3.internal DMZ Server and BizTalk server can access each other
    What is the best solution from your idears? I am look forward your wonderful sharing.
    Phile

    #3 is the most common scenario, but to BizTalk and your app, it doesn't matter.
    What you need to find out first from you security team is whether or not they will allow a connection to be made directly to the BizTalk computer or require proxying.

  • Implement strategy for ASA on TACACS w/ restricted read-only access

    An ASA5550 will need to be configured to use TACACS AAA. Currently, the ASA is setup for local authentication. A couple of privilege 15 admin users and a few more privilege 5 read-only users.
    ASA 5550
    running ASA 8.2(2)
    using ASDM 6.3(5)
    authenticating to ACS 4.2
    The admin users and read-only users already have established TACACS usernames and are in established TACACS user groups for logging into routers/switches.
    What's the best way to implement configuration of the ASA and ACS server to maintain the same type of restrictions that's applied using the local database?
    1. Try and avoid the creation of a second TACACS username for the admin and read-only users.
    2. ACS allows restrictions on what devices can be access by users/groups. Possible to do reverse? Restrict what usernames can access a device in the ACS database.

    If you want to configure ASA for read-only access via tacacs then you have to do the following task
    ASA/PIX/FWSM Configuration
    In addition to your preset configuration, these commands are required on ASA/PIX/FWSM in order to implement command authorization through an ACS server:
        aaa-server authserver protocol tacacs+
        aaa-server authserver host 10.1.1.1
        aaa authorization command authserver
    On the ACS, you need to create command authorization set for only SHOW commands:
    http://www.cisco.com/en/US/products/sw/secursw/ps2086/products_configuration_example09186a00808d9138.shtml#scenario2
    Associate command authorization set with user or group
    http://www.cisco.com/en/US/products/sw/secursw/ps2086/products_configuration_example09186a00808d9138.shtml#asso2
    Regards,
    Jatin
    Do rate helpful posts-

  • 17076 : Invalid operation for read only resultset

    Hi,
    I am trying to update database table through java jdbc application.
    But while running the program i am getting the error message " Invalid operation for read only resultset: updateString " with error code 17076.
    My program is given below :
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    public class Misc2 {
    public static void main(String[] args) {
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;
    try {
    con = JDBCUtil.getOracleConnection();
    stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    String query = "select * from employees";
    rs = stmt.executeQuery(query);
    while (rs.next()) {
    String fname = rs.getString(3);
    if (fname.equalsIgnoreCase("Elmer")) {
    rs.updateString(3, "Mark");
    rs.updateString(2, "Robert");
    break;
    } catch (SQLException ex) {
    System.out.println("error code : " + ex.getErrorCode());
    System.out.println("error message : " + ex.getMessage());
    } finally {
    JDBCUtil.cleanUp(con, stmt);
    ****JDBCUtil Class****
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.Statement;
    public class JDBCUtil {
    public static Connection getOracleConnection(){
    Connection con = null;
    try{
    // Load the driver
    Class.forName("oracle.jdbc.driver.OracleDriver");
    //Establish Connection
    con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","ex","ex");
    }catch(Exception ex){
    ex.printStackTrace();
    return con;
    public static void cleanUp (Connection con , Statement stmt){
    // Release the resource
    try{
    if(con != null){
    con.close();
    if(stmt != null){
    stmt.close();
    }catch(Exception ex){
    ex.printStackTrace();
    Please help me to fix this issue.

    >
    But while running the program i am getting the error message " Invalid operation for read only resultset: updateString " with error code 17076.
    >
    Your result using 'SELECT *' is not updateable. Gimbal2 was pointing you in the right direction. You have to specify the columns in the select list to get an updateable result set.
    You also need to use 'updateRow()' to update the database and have a commit somewhere to keep the results.
    This code works for me. Note that I added an explicit SELECT list, the 'updateRow()' method and an explicit COMMIT.
        try {
            con = getOracleConnection();
            stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    //        String query = "select * from employees";
            String query = "select first_name from employees"; -- added explicit SELECT list
            rs = stmt.executeQuery(query);
            while (rs.next()) {
                String fname = rs.getString(1);
                if (fname.equalsIgnoreCase("Adam")) {
                    rs.updateString(1, "Mark");
                    rs.updateRow();                                    -- need this statement to actually update the database
    //                rs.updateString(2, "Robert");
                    break;
            con.commit(); -- added explicit commit for testing
        } catch (SQLException ex) {See Performing an UPDATE Operation in a Result Set in the 'Updating Result Sets' section of the JDBC Developer's Guide and Reference
    http://docs.oracle.com/cd/B28359_01/java.111/b31224/resltset.htm#i1024720
    As gimbal2 also alluded it is considered poor practice to use column numbers to perform result set operations when you don't know for certain what column a given number refers to. Before people start jumping all over that statement let me clarify it. The key part is KNOWING what column you are referencing. It is more performant to access result column columns by column number rather than by column name since the methods that take a column name call the integer method under the covers anyway but have to search the array of column names in order to get the column number.
    With your query (SELECT *) there is no way to be sure the column order is the same since the table could be redefined with the columns in a different order or certain columns having been deleted. So for performance LOOP processing column numbers are used inside the loop but those column numbers are determined by using the metadata BEFORE the loop to convert column names to column numbers.
    That way you code (BEFORE the loop) can use column names but you use a set of integer variables (one for each column) for the actual access inside the loop.

  • Read Only access to UCCX server

      Hi,
    I would like to know if it was possible to create an account for Read Only access for server in UCCX 8.02.
    Saima

    Saima,
    Unfortunately no it is not, you have either Admin access or supervisor access. The admin access has full access and supervisor access allows configuration of the RM subsystem either foe own team or all teams.
    HTH,
    Chris

  • Read only access to J2EE related tools

    Hello,
    I would like to help our auditors access everything they need to check in the Java systems, but I am not ready to give them ADMIN accounts. That`s why I need some kind of read only access for them.
    So I would like to ask you if there is a SAP Note about the read only access roles for J2EE/ Java AS?
    I am afraid there is no such note available, so can anybody share any experience with granting read only access to the Java system? I know how to grant access to the whole NWA, but what about the rest?
    Examples:
    - is there a way how to grant read only access only to the UME?
    - is there a role for read only access to the portal PCD?
    - is there something similar for KM access?
    Or has anybody ever tried to split the admin roles into smaller pieces? Is there a description/ document how to do such thing?
    Thank you for your time and effort,
    cheers Otto

    Hi,
    thanks for trying, but I can use help.sap.com and was on that page before.
    Maybe if there were any examples there or better: if the whole thing would be more granular (I see no point in using roles starting with SUPER, containing ADMIN or ending with ALL). I am looking for roles for surgery or for auditing. I don`t want to give anybody these super/admin/all roles just like that.
    If you can suggest how to use that page, that would be cool. Otherwise I see no use.
    By the way: another question of mine about surgery: How to restrict access to download/ upload UME configuration file
    I would like to know how to controla access to this specific feature, nothing else.
    Thanks for the time and effort,
    cheers Otto

  • Avoid read-only access at physical standby

    Hi!
    DB=11.2.0.2
    when I start the standby with
    SQL> startup
    the db is open read-only.
    Is there a way to configure the db so that startup command only mounts the db and start redo apply?
    this is the config:
    DGMGRL> show configuration verbose;
    Configuration - w
    Protection Mode: MaxPerformance
    Databases:
    w_01 - Primary database
    w_02 - (*) Physical standby database
    (*) Fast-Start Failover target
    Properties:
    FastStartFailoverThreshold = '30'
    OperationTimeout = '30'
    FastStartFailoverLagLimit = '30'
    CommunicationTimeout = '180'
    FastStartFailoverAutoReinstate = 'TRUE'
    FastStartFailoverPmyShutdown = 'TRUE'
    BystandersFollowRoleChange = 'ALL'
    Fast-Start Failover: ENABLED
    Threshold: 30 seconds
    Target: w_02
    Observer: ora
    Lag Limit: 30 seconds
    Shutdown Primary: TRUE
    Auto-reinstate: TRUE
    Configuration Status:
    SUCCESS
    DGMGRL> show database w_02
    Database - w_02
    Role: PHYSICAL STANDBY
    Intended State: APPLY-ON
    Transport Lag: 0 seconds
    Apply Lag: 0 seconds
    Real Time Query: OFF
    Instance(s):
    w
    Database Status:
    SUCCESS
    br
    Daniel

    If Data Guard is setup correctly the application is not losing data, you cannot read from it, but it will apply logs:
    Ex.
    /home/oracle:STANDBY >sqlplus "/ as sysdba"
    SQL> select * from BIGSHOW.CUSTOMER;
    select * from BIGSHOW.CUSTOMER
    ERROR at line 1:
    ORA-01219: database not open: queries allowed on fixed tables/views only
    So even as the SYS user I cannot read from my test user's tables.
    ORA-01219 is expected when the standby is in this state.
    You can open READ ONLY if you have Active Data Guard, but generally that will cost you extra.
    OR, you can do thing to check your data:
    To open a standby database for read-only access when it is currently performing managed recovery:
    Cancel log apply services:
    SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
    Open the database for read-only access:
    SQL> ALTER DATABASE OPEN READ ONLY;
    At some point you have start the recovery again, you probably don't have an issue.
    If you want more peace of mind on this you have to setup a test Data Guard system and bang on it.
    Best Regards
    mseberg

  • Can't get read-only access to my switches via http

    I set up a couple of users for read-only access to our switches via their web browsers. I set this up in Network Assistant. However when we try to log in, only a level 15 user is allowed to log in and there doesn't seem to be any way change this.
    I know in Network Assistant, you can choose which user level you want, but I don't see any way to do it via the web interface.
    What am I missing here?

    Implementing security within a switching environment is less intuitive than in a router. Switches, by design, tend to recognize only two levels of administrative access - user exec mode or privileged exec mode. Implementation of security at different access levels, level 15, etc, can be tricky and should be done at the command prompt, not in the GUI.
    You should reset your config and do not use Network Assistant for this purpose; it is "buggy."

  • On imac 10.6.8 using current version of Aperture.  How can I access the Aperture Library  on my external hard drive that I use with time machine for backup?  I can only access the application but not the library..

    On imac 10.6.8 using current version of Aperture.  How can I access the Aperture Library  on my external hard drive that I use with time machine for backup?  I can only access the application but not the library..

    Go into Time Machine (the program not the bundle on the extrnal disk) and using Time Machine's browser go to the Folder where the library lives. You could look in the library bundle in Time Machine but that won't really tell you much,
    If you want to make sure it truely has backed up your library you will need to restore it and open the restored library with Aperture.
    If all this still has you confused you need to read up on Time Machine in order to get a feel for how it works, for what it is doing and for how to restore files from it.

  • I have a production mobile Flex app that uses RemoteObject calls for all data access, and it's working well, except for a new remote call I just added that only fails when running with a release build.  The same call works fine when running on the device

    I have a production mobile Flex app that uses RemoteObject calls for all data access, and it's working well, except for a new remote call I just added that only fails when running with a release build. The same call works fine when running on the device (iPhone) using debug build. When running with a release build, the result handler is never called (nor is the fault handler called). Viewing the BlazeDS logs in debug mode, the call is received and send back with data. I've narrowed it down to what seems to be a data size issue.
    I have targeted one specific data call that returns in the String value a string length of 44kb, which fails in the release build (result or fault handler never called), but the result handler is called as expected in debug build. When I do not populate the String value (in server side Java code) on the object (just set it empty string), the result handler is then called, and the object is returned (release build).
    The custom object being returned in the call is a very a simple object, with getters/setters for simple types boolean, int, String, and one org.23c.dom.Document type. This same object type is used on other other RemoteObject calls (different data) and works fine (release and debug builds). I originally was returning as a Document, but, just to make sure this wasn't the problem, changed the value to be returned to a String, just to rule out XML/Dom issues in serialization.
    I don't understand 1) why the release build vs. debug build behavior is different for a RemoteObject call, 2) why the calls work in debug build when sending over a somewhat large (but, not unreasonable) amount of data in a String object, but not in release build.
    I have't tried to find out exactly where the failure point in size is, but, not sure that's even relevant, since 44kb isn't an unreasonable size to expect.
    By turning on the Debug mode in BlazeDS, I can see the object and it's attributes being serialized and everything looks good there. The calls are received and processed appropriately in BlazeDS for both debug and release build testing.
    Anyone have an idea on other things to try to debug/resolve this?
    Platform testing is BlazeDS 4, Flashbuilder 4.7, Websphere 8 server, iPhone (iOS 7.1.2). Tried using multiple Flex SDK's 4.12 to the latest 4.13, with no change in behavior.
    Thanks!

    After a week's worth of debugging, I found the issue.
    The Java type returned from the call was defined as ArrayList.  Changing it to List resolved the problem.
    I'm not sure why ArrayList isn't a valid return type, I've been looking at the Adobe docs, and still can't see why this isn't valid.  And, why it works in Debug mode and not in Release build is even stranger.  Maybe someone can shed some light on the logic here to me.

  • Access for update only one column in table?

    Hi all,
    My need is to grant access for update only one column c1 in table t1.
    I guess I should use view, could you please give me some example? Maybe other ideas?

    Hi,
    You can grant privileges on individual columns.
    GRANT   UPDATE (c1)
    ON      t1
    TO      grantee_name;Look up GRANT in the SQL language manual. Annoyingly, in recent editions of the manual, GRANT is not indexed, but it's in alphabetic order with all the other statements:
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_9013.htm#i2155015

  • How to configure Mailbox Read-Only access for Mailbox's owner on Exchange Server 2010?

    I have to configure the Exchange Server 2010's mailbox to only grant Read-Only Access on the mailbox's owners.  So they can only allowed to read their messages and cannot modify or remove them.  Are there any references or methods to do?

    Hi,alexchy8
    We can make use of 2 PowerShell commands to achieve this goal.
    Add-MailboxPermission and Add-MailboxFolderPermission.
    Execute the Add-MailboxPermission command to delegate the read permission at mailbox level.
    Execute the Add-MailboxFolderPermission command to delegate the required permissions on specific folders inside the mailbox.
    You can read the following article as reference:
    http://www.exchangedictionary.com/articles/assign-read-only-mailbox-permission-on-exchange-2010-2013-powershell
    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety,
    or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.
    Best Regards.

Maybe you are looking for

  • Auto login?

    Is there anyway I can set up to automatically login in whenever I visit the forum. With most other forums I am given the option to add info to the keychain by Safari and then when I revisit the site, even after restarting, I am automatically logged i

  • Motion 7.0 = 7344 no more found

    Hello, i just installed a PCI7344 and the Motion 7.0 . Now there is no more PCI7344 available in the MAX, well it is detected as a card, vendor is NI but there is not "motion device" folder and no 7344. MAX update (F5)  did not help. Renaming the dat

  • How do I make the fount of my web search results bigger

    I am not able to read the web results because the fount is too small. Some pages do not let me zoom either. The settings only makes the fount bigger for typing messages.

  • IMac blank screen at start up, just fan whirl.

    Well I've got myself a bit of a problem, my computer is usually left on all the time with the odd restart here and there, anyway it got turned off today while I was out of the house and now it's stopped working. Simply put, after the startup chime th

  • After install the trial version of LR 2.3, it only displays as grayscale.

    I installed the trial version of Lightroom 2.3. When I open the program and import pictures, I can only see them as grayscale images. I feel stupid, but what am I doing wrong? How can I view them as the color images they are and edit them? Thanks, Ph