Monitor State of an Object

Is there a way to check the monitor state of an object? For example,
before entering a synchronized block I want to check if there is a monitor on the object and skip the block so the thread is not forced to wait. Thanks in advance.

I don't think so...
But you can use higher-level concurrency constructs to do this. For example, you could design a lock which allowed you to attempt to lock, or give up. Doug Lea has written an excellent book on concurrency, and also has a library of concurrency utilities called "util.concurrent" available online. His page is at:
http://gee.cs.oswego.edu/dl/cpj/
In particular, he has a Semaphore object with a method public boolean attempt(long msecs). You'll also need to use try/finally to make sure you release any locks you acquire.
The book is a great read -- I recommend it.

Similar Messages

  • Share Point 2013 MP for SCOM 2007 R2 - Not Monitored State

    Hi All,
    I have imported SharePoint 2013 MP in SCOM 2007 R2 and the sharepoint farm group is in "not monitored" state, moreover only one computer name out of all sharepoint farm servers is being populated in unidentified machines (rest are not being
    shown anywhere in Microsoft SharePoint folder).
    I have followed all the steps as per installation guide of sharepoint 2013 (foundation & Server) MP. Configured run as account has the farm admin rights.
    Please help as it seems discovery is not working properly.
    Regards,
    Prabh.

    Hi,
    Hope the below blog be helpful:
    Configuring the SharePoint 2013 Management Pack
    http://blogs.technet.com/b/kevinholman/archive/2013/05/14/configuring-the-sharepoint-2013-management-pack.aspx
    Please go through it.
    Regards,
    Yan Li
    Regards, Yan Li

  • Error occurred in deployment step 'Add Solution': Operation is not valid due to the current state of the object

    hi,
      when i was trying to deploy a SP  solution from my vs 2012 solution. this error  is displayed.
    i tried many things like
    1) get the wsp and apply power shell cmds to add and deploy, here also it failed:
    Add-SPSolution -LiteralPath d:\mywsp.wsp
    Install-SPSolution mywsp.wsp -GacDeployment -AllWebApplications -Local
    2) restart the timer services and  do  iisreset and  reboot the server. etc .as mentioned in one of the  the below  blogs:
    http://sharepoint1on1.blogspot.in/2014/04/sharepoint-error-occurred-in-deployment.html
    http://suehernandez.wordpress.com/2011/03/31/error-occurred-in-deployment-step-activate-features-operation-is-not-valid-due-to-the-current-state-of-the-object/
    http://www.dotnetsharepoint.com/2014/04/error-occurred-in-deployment-step-add.html
    http://social.msdn.microsoft.com/Forums/en-US/63adde23-03cf-4b65-923e-1219da94a780/error-occurred-in-deployment-step-add-solution-operation-is-not-valid-due-to-the-current-state-of?forum=sharepointdevelopmentprevious
    http://www.shakirmajeed.com/error-occurred-in-deployment-step-activate-features-operation-is-not-valid-due-to-the-current-state-of-the-object/
    but even after doing all these steps, the  error still persists!. and am not deploying into a remote server, the dev env is in a VM, where sp 2013, vs 2012, sql 2012  are installed.
    just wanna share one  note:   there is a isue in my search admin component. index was reset due to some reason. and from that time onwards my search full/incremental crawls were not working!
    will this cause an issue in my wsp deployment ? i hope  it wont, still  asking...
    can anyone help me how to resolve this error.because this is a  show stopper for me for the last few days!
    help is highly appreciated!

    This issue cause because of feature activation failure while WSP deployment.
    when you create a WSP using visual studio, it creates WSP package with default deployment configuration settings.
    Please restrict feature activation configuration, this will help you to troubleshoot this issue.
    - Click on Project in WSP and press F4, it will open "Project Properties"
    - set "Active deployment Configuration" - as "No Activation"
    - you can activate this features in required sequence after deployment using Activate-SPFeature
    If my contribution helps you, please click Mark As Answer on that post and Vote as Helpful
    Thanks, ShankarSingh(MCP)

  • Error_27_Error occurred in deployment step 'Activate Features': Operation is not valid due to the current state of the object.

    I created a SharePoint 2013 farm solution project in Visual Studio 2013 (running on the same machine where SharePoint 2013 server is running) with
    event receiver.  I added web.config at project root level to store connection string (I'm working off external SQL DB) and got the following error during deployement:
    Error 27
    Error occurred in deployment step 'Activate Features': Operation is not valid due to the current state of the object.
    When I commented out the ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString; the error went away.  Am I missing something or not supposed to add my own App.config to SharePoint project solution? 

    Hi,
    From your description, you might want to store your connection string in web.config and there is an error during deployment.
    It is recommended to store the configuration data of SharePoint solution in either property bags or hierarchical object store.
    The links below will provide more information about this:
    http://blogs.msdn.com/b/zwsong/archive/2012/03/27/where-should-you-store-your-sharepoint-solution-s-configuration-data.aspx
    http://msdn.microsoft.com/en-us/library/ff647766.aspx
    Thanks
    Patrick Liang
    Forum Support
    Please remember to mark the replies as answers if they
    help and unmark them if they provide no help. If you have feedback for TechNet
    Subscriber Support, contact [email protected]
    Patrick Liang
    TechNet Community Support

  • A function containing switch statement and foreach-object loop

    Hello Guys
    in my testdomain.lab, i have following five OUs in mt test AD structure:
    'OUusers', 'OUcomputers','OUservers','OUadministrators','OUhelpdesks'.
    i have created following five variables:
    $OUusers = 'ou=OUusers,dc=mytestdomain,dc=lab'
    $OUcomputers = 'ou=OUcomputers,dc=mytestdomain,dc=lab'and so on
    now i have created a function which gets this names as input &
    foreach-object creates the related OU.
    but the problem is sometimes when i run my function, maybe some of those five OUs
    currently exist in AD so this will cause a
    terminating error. 
    so i know i must use switch statement to define conditions like this:
    if $OUusers doesn't exist, execute this :  new-ADOrganizationalunit $OUusers
    if $OUcomputers doesn't exist, execute this :  new-ADOrganizationalunit $OUcomputers
    and so on...
    it's a long time which i am trying to create a
    function which contains such switch statement & properly forEach-object loop.
    i have studied switch and foreach-object loops , but this scenario is complicated for me & i was unable to get the correct code.
    Function createOUs {
    # combination of ForEach-Object and Switch statement here
    may someone give me the correct
    command please?
    thanks a lot

    Like this:
    $CompanyRoot=tha'ou=MyCompany, dc=mytestdomain,dc=lab'
    New-ADOrganizationalUnit -Name MyCompany -ErrorAction SilentlyContinue
    $ous='Users', 'Computers','Servers','Administrators','Helpdesk'
    foreach($ou in $ous){
    New-ADOrganizationalUnit -Name $ou -Path $companyroot -ErrorAction SilentlyContinue
    ¯\_(ツ)_/¯
    jrv, That can't be the solution because when you running a command which tries to creates an OU
    which already exist in AD, causes a
    terminating error which has two caveats:
    1- shows red error message on screen
    2- stops and doesn't continue to execute next lines of code
    Note that -ea silentlycontinue and -ea ignore have no effect on
    terminating errors and they cn't hide error messages, also script can't continue.
    i examined that.
    to get sure, run this function in your test AD & see the result:
    function createOUs {
    New-ADOrganizationalUnit -Name 'an-existing-ou' -Protected 0 -ea SilentlyContinue # you see that -ea silentlycontinue has no effect here
    New-ADOrganizationalUnit -Name '2ndOU' -Protected 0 -ea SilentlyContinue # you see that because the previous error has been a terminating error, command execution has been stopped and this 2nd OU hasn't been creatde
     another bad news is ( as i tested), if we query for an Organizational Unit which doesn't exist in AD , it generates a terminating error as well, so again here -ea has no effect.
    test this:
    PS C:\> Get-ADOrganizationalUnit -identity 'ou=nonesense,dc=yourDomain,dc=lab' -ea ignore
    error doesn't disapear ;-)

  • Objects states in an object state

    I am finding it impossible to insert an object state into a state of another object state...
    So that in object state 1 there is another series of object states (B) that would disappear once object state 1 goes to the next state...
    the end result I am trying to achieve is to have a question in an object state that the user can touch to show the answer...
    example: state 1 appears a question...when you touch it the answer appears, in state 2 a different question/answer etc...

    @hooplife – there are two solutions:
    1. InDesign CS5: copy or cut the MSO to the clipboard, paste after selecting the one and only insertion point in the empty text frame with your text tool (= double click the text frame with the selection tool). You can change position of the inserted MSO by using the anchored object options.
    2. InDesign CS5.5 and above:
    if you select an object you may have noticed that there is a new control on every object: the small blue square. Hover your mouse pointer over the square and just follow the instructions of the tool tip.
    In case you have disabled the tool tips function:
    Simply drag the little blue square to the one and only insertion point in the empty text frame.
    Use shift + drag to get the same result like pasting the MSO to the insertion point or:
    use alt + drag to immediately getting the options for anchored objects.
    Uwe

  • How to recover a state of  one objects threads by other object

    hi everyone
    how to recover a state of one object's threads by other object..
    i am creating a object in that i have 10 thread..... i have started it then i have closed that object ...then i am creating a new object for the same class ...i need to stop those thread which i have started earlier

    saiyath_babuhussain wrote:
    hi everyone
    how to recover a state of one object's threads by other object..Objects don't own threads so that's hard to understand
    >
    i am creating a object in that i have 10 thread..... i have started it then i have closed that object ...then i am creating a new object for the same class ...i need to stop those thread which i have started earlierWe don't so much stop threads as inform them politely that their services are no longer required. When you have a long running thread it's almost always a loop, often with a wait or sleep which causes it to wait until it's activitty is needed.
    So if you want to be able to wind up a thread from another thread then you put a boolean flag in which can break the loop. The other thread then changes that flag and calls interupt() on the thread it's trying to stop. Interupt will kick the thread out of wait or sleep if that's where it is, causing an InterruptedException. On discovering that the flag indicates it should stop, or on catching an InterruptedException the thread should then clean up and finish.
    The master thread can call join on the thread it's stopping if it needs to wait for it to terminate.

  • Illegal monitor state exception?

    hi, I am writing a rmi server/client readers/writers type program. server has syncronized start read/stop read methods and also start write/stop write. these are controlled by int variables to give writers priority as ilustrated below
    public synchronized String startReading(int yLoc, int xLoc)
              int tempVal = 0;
              String returnMess = "";
              try
         nrtotal++;               // ADD ONE TO TOTAL READERS
         if (nwtotal!=0) // IF WAITING WRITERS
                        System.out.println("\nClient waiting to read");
                        wait();
         nr++;          // INCREASE NUMBER OF READERS BY ONE
                   tempVal = memory[yLoc][xLoc];
                   //System.out.println("\nClient read "+tempVal+ " from location y:"+yLoc+" x:"+xLoc);
                   returnMess = "\nClient read "+tempVal+ " from location y:"+yLoc+" x:"+xLoc;
              catch(InterruptedException e)
                   System.out.println("startReading:"+e.toString());
              return returnMess;
    The problem is that the read methods should not really be synchronized, so multiple readers can read at the same time. The write methods remain synchronized, but if i change the read methods to normal: public string startreading(etc,etc) when i run the remote client and call the rmi server method to read I get an illegal monitor state exception in main. does anyone know why?
    Thanks

    synchronizing is allowing you to have multiple readers working concurrently.
    When the startReading method is invoked it puts a temporary lock on itself. As soon it completes the next thread can access the method.
    So in essence, you have a group of threads running for each reader. If a reader makes a call on the startReading method it will wait for its turn.
    Should the thread that is accessing the method get detained, locked, or simply have an enormous amount of reading to do, it can seem that the reader is slow and not working concurrent threads.

  • Is it possible to monitor State change of a .CSV file using powershell scripting ?

    Hi All,
    I just would like to know Is it possible to monitor State change of a .CSV file using powershell scripting ? We have SCOM tool which has that capability but there are some drawbacks in that for which we are not able to utilise that. So i would like
    to know is this possible using powershell.
    So if there is any number above 303 in the .CSV file then i need a email alert / notification for the same.
    Gautam.75801

    Hi Jrv,
    Thank you very much. I modified the above and it worked.
    Import-Csv C:\SCOM_Tasks\GCC2010Capacitymanagement\CapacityMgntData.csv | ?{$_.Mailboxes -gt 303} | Export-csv -path C:\SCOM_Tasks\Mbx_Above303.csv;
    Send-MailMessage -Attachments "C:\SCOM_Tasks\Mbx_Above303.csv" -To “[email protected]" -From “abc@xyz" -SMTPServer [email protected] -Subject “Mailboxex are above 303 in Exchange databases” -Body “Mailboxex are above 303 in Exchange databases" 
    Mailboxex - is the line which i want to monitor if the values there are above 303. And it will extract the lines with all above 303 to another CSV file and 2nd is a mail script to email me the same with the attachment of the 2nd extract.
    Gautam.75801

  • Unable to write more than 10 case statements in an object in designer

    unable to write more than 10 case statements in an object in designer
    XI 3.0 and XI 3.1
    Please let me know, any known issues.

    Hi,
    yes this is the limitation you cant write more that 10 case statments but you can reduce the number of time you use the case in your object.
    For ex:
    If you are writing few conditions on one field then you can add the login in one case only.
    case when SAL between 100 and 1000 then 'lowsal'
            when SAL between 1000 and 2000 then 'medsal'
            when sal between 2000 and 3000 then highsal
    else
    case when ...then ....
    else
    end
    end
    by following the above ex you can solve your problem.
    But if you are writing case statement based on dofferent columns then write 10 case statements and remaining conditions you can add at the report level.
    using if else condition.
    Hope this will help you....
    Cheers,
    Ravichandra

  • WCF Service update UPS. Operation is not valid due to the current state of the object.

    I try import custom data to custom user properties from my own wcf service (on sharepoint server machine), but i got
    Message "Operation is not valid due to the current state of the object. "
    on line
    userProfile[PropertyConstants.Department].Value = "SDDDD";
    Why i cant modify property value?
    SPSecurity.RunWithElevatedPrivileges(delegate()
    using (SPSite site = new SPSite("http://portal.local"))
    SPServiceContext serviceContext = SPServiceContext.GetContext(site);
    using (var web = site.OpenWeb())
    Debug.WriteLine(web.CurrentUser); //Here AppPoolAccount user of current wcf service
    Debug.WriteLine(WindowsIdentity.GetCurrent().Name); //Here too AppPoolAccount user of current wcf service
    UserProfileManager userProfileMgr = new UserProfileManager(serviceContext);
    ProfilePropertyManager profilePropMgr = new UserProfileConfigManager(serviceContext).ProfilePropertyManager;
    ProfileSubtypePropertyManager subtypePropMgr = profilePropMgr.GetProfileSubtypeProperties("UserProfile");
    UserProfile userProfile = userProfileMgr.GetUserProfile(accountName);
    userProfile[PropertyConstants.Department].Value = "SDDDD";
    userProfile.Commit();
    My service running under domain\SPSvcAcc what have full permissions on UPS service, it's management account and UPS admin with full rights.
    If i create console app with identical code and run it under SPSvcAcc account it working without problems
    What i do wrong?

    Hi,
    pls seee if you can add threading like this below to solve the pbm
    https://social.technet.microsoft.com/Forums/office/en-US/b6d6f85c-e12b-4540-a821-690e296b7b56/operation-is-not-valid-due-to-the-current-state-of-the-object-exception-when-activating-a?forum=sharepointdevelopmentprevious
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • Microsoft RMS Add-in Operation is not valid due to the current state of the object

    Microsoft Rights Management sharing application for Windows
    Microsoft Windows 7/Office 2010 Service Pack 2
    Click 'Share Protected'
    Receive the following error message 'Microsoft RMS Add-in Operation is not valid due to the current state of the object'
    Microsoft Windows 7/Office 2013 Service Pack 1
    Works fine
    Any ideas why this is not working?

    Hi lra,
    As per my understanding, I think this issue can be caused by MaxHttpCollectionKeys settings in report manager web.config file.
    For more details, please refer this similar thread to override the default value of MaxHttpCollectionKeys:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/cb6ede72-6ed1-4379-9d3c-847c11b75b32/report-manager-operation-cannot-run-due-to-current-state-of-the-object?forum=sqlreportingservices
    Hope this helps.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • "Operation is not valid due to the current state of the object" error when trying to create a link for a shared folder in OneDrive

    I'm trying to share a folder in OneDrive with another user in my organization, and create a link so that people outside of the company can see the folder. Whenever I try to create a link I get an error that says: "Couldn't create the link sorry something
    went wrong operation is not valid due to the current state of the object" How do I resolve this?

    Hi,
    Sorry for replying late and I noticed that you posted another thread in this forum:
    http://social.technet.microsoft.com/Forums/en-US/2b8c6f54-9c59-4b37-b28f-1d49a1b7913b/operation-is-not-valid-due-to-the-current-state-of-the-object-error-when-trying-to-create-a-link?forum=officeitpro
    I've replied and kindly refer to it to see if it is helpful.
    Regards,
    Melon Chen
    TechNet Community Support

  • SCOM 2012 SP1 exchange edge transport queue is showing as not monitored state.

    Hi,
    We have exchange servers which is being monitored by both SCOM 2007 and SCOM2012 SP1, in SCOM 2007 R2 exchange edge queue is getting discovered, but in SCOM 2012 SP1 it is showing as not monitored state.
    Please help me in resolving this issue.

    Hi,
    What kind of MP did you import on SCOM 2012? Meanwhile, please try the following suggestions.
    1. Start the Remote Registry service. 
    2. Enable File and Printer Sharing 
    3. Check the network connectivity between the management server and the Exchange Server and ensure the FQDN of the Exchange Server can be resolved. 
    4. Clear the HealthService queue on the Exchange Server:
    a. Stop System Center Management service.
    b. Go to C:\Program Files\System Center Operations Manager 2007\, and rename the “Health Service State” folder.
    c. Restart System Center Management service.
    Niki Han
    TechNet Community Support

  • Generate "Drop-Statements" for DB-Objects

    Hi,
    is it possible to generate drop statements for the different DB-Objects?
    Most of the time when I generate DDL - Statements for Tables and Sequences I need a drop statement for this object to recreate.
    And is it possible to supress the schema-name?
    CREATE TABLE "SCHEMA"."TABLE"
    Regards, Juergen
    Message was edited by:
    Juergen.Schuster
    Message was edited by:
    Juergen.Schuster

    I apologize. I had interpreted the first posting in the thread differently than you. I had read "Most of the time when I generate DDL - Statements for Tables and Sequences I need a drop statement for this object to recreate" to mean that when the user generates the DDL for a table or sequence include a DROP statement prior to the CREATE statement. If these were automatically generated and the user accidentally ran the script, they may lose data in the table or the value of the sequence. That is why I was suggesting that the DROP statement generation be configurable when DDL for a table is generated.
    My mistake,
    Mike

Maybe you are looking for

  • How to use Cursor's Fetch to return multiple column Data

    Hi , This is my Table : SQL> select * from Login; USERNAME PASSWORD CONFIRMPASSWORD RAvi SAI SAI Kiran Keyboard Keyboard VARNU JAINA JAINA This is my stored Procedure , for that Table , this is working fine , where he Cursor's Fetch is returning only

  • Stop error in phase START_SHDI_FIRST

    hi, we are upgrading from 4.6c to ecc6.in the phase START_SHDI_FIRST shadow instance is not starting. below is the dev_trc trc file: "dev_disp.new", trc level: 1, release: "700" sysno      04 sid        DEV systemid   324 (IBM iSeries with OS400) rel

  • Missing em.ear file while installing 11gR2 in windows 2003 R2

    hi, i have downloaded the oracle 11gR2 for windows 32 bit version but while installing "copying files" i am getting the error "file missing <>\applicatons\OC4J\em\em.ear and em.war files... is there files missed while down loads? i have two zip files

  • Need to maintain default

    I need to maintain a default delivery block and shipping conditions for a particular sales area for a returns sales document(va01-Z31) which we use it should come has a default. i need to do the changes for existing returns document type to my knowle

  • Good tutorial for using the orielly file upload servlet

    Hello all, I just downloaded the packages from the orielly site and I am interested in using the upload servlet. I have the oreilly servlet book but it doesnt get into much detail about how to use the servlet. I have not used servlets before so I nee