What is Thread Safety in timer jobs on SharePoint?

Hi All,
What is Thread Safety in timer jobs on SharePoint?
Thanks in advance!

hi
thread safety in timer jobs means the same as in other code: it should be possible to run multiple instances of the same job simultaneously. If job uses some shared resource, access to this resource should be synchronized. But the tricky moment is that it
is not enough to just use standard .Net thread synchronization mechanisms here (e.g. lock), because in most cases Sharepoint runs on the server farm and the same job instance may be executed on different servers while standard synchronization mechanisms work
within single process memory space (it is possible to guarantee that jobs are running on the same server by assigning preferrable server for timer jobs in Central administration > Content databases > content database, but often it is left to Sharepoint
to decide on what server jobs are executed). In case of timer jobs you need to store some flag that job is started in some shared storage, e.g. in SPWebApplication.Properties:
lock(obj)
try
if ((bool)web.AllProperties["jobstarted"])
return;
web.SetProperty("jobstarted", true);
web.Update();
finally
web.AllProperties.Remove("jobstarted");
web.Update();
It is just idea and there is still minor possibility that 2 jobs instances may run at the same time (if 2nd job instances set jobstarted flar after 1st jobs checked it in AllProperties, but before 1st jobs set it), but it will solve most of the problems in
reality. In order to make the code more secure you may use timestamps instead of flag.
Blog - http://sadomovalex.blogspot.com
Dynamic CAML queries via C# - http://camlex.codeplex.com

Similar Messages

  • How to Create Custom Timer Job for SharePoint 2010 using Visual Studio 2010?

    While creating timer job Visual Studio showing some kind of error and assembly issues.

    Hi Aryav
    Please provide the errors so that we can resolve your issue.
    Meanwhile go through the step by step process of creation of Timer Job in the articles given below.
    Create and Deploy Custom Timer Job Definition in SharePoint Programatically
    Indul Hassan
    Microsoft Community Contributor
    http://www.indulhassan.com
    You Snooze.. You Lose !!

  • Force immediate alerts timer job to run on a particular server

    In Central Admin->Manage Content Database->Preferred server for timer jobs says "Not selected".  We have 2 WFE servers, server1 and server2.  server1 currently is not able to connect to the smtp server so we would like for the immediate
    alerts timer job to be executed on server2 which has access to smtp.  I know I could set the preferred server for timer jobs to be server2 but that would mean that all timer jobs would execute on that server.
    I have a few questions:
    1. Is there a way to force just immediate alert timer job to run on server2?
    2. How can I find out which server is currently processing the immediate alerts timer job (or which server processed the last immediate alerts timer job)
    3.  If I force all timer jobs to execute on server2, how much of an effect does it have on the server in terms of RAM, CPU and other resources?
    thanks,

    What i believe is, alerts timer jobs is ContentDatabase Locktype so if you select the prefred server from the Central admin.
    I am sure, all the timer jobs which having the ContentDB lock type will run on preferred server.
     Note that content database locks are handled at the server and database level, not at the individual job level.
    The Article Trevor mentioned is great for explanation.
    2.) you can check it from the Central admin > Monitoring  > Job History and from here select the job definition which history you want
    to see.
    3)you forcing all timer jobs in one server that's mean you are increasing the over head for that server so performance may be issue. Its depend how many user / load you already have
    on the server. another thing, may be deadlock between the jobs i.e if one job took more time and other jobs wait for it ends up skipping it.
    Please remember to mark your question as answered &Vote helpful,if this solves/helps your problem. ****************************************************************************************** Thanks -WS MCITP(SharePoint 2010, 2013) Blog: http://wscheema.com/blog

  • Microsoft SharePoint Foundation Usage Data Import Timer Job Fails on two of six servers

    Starting about one week ago this timer job started to fail on my two WFE's in a newly implemented SP2013 Farm, the ULS error and verbose details are below..Thanks.
    03/19/2015 15:55:58.54 OWSTIMER.EXE (0x30D4) 0x7748 SharePoint Foundation Timer 6398 Critical The Execute method of job definition
    Microsoft.SharePoint.Administration.SPUsageImportJobDefinition (ID 676104fa-9a64-4936-a6cd-986223176db5) threw an exception. More information is included below. Index was outside the bounds of the array.
    825cf49c-2b6d-a0a5-c45a-88e7d3e4ed5d
    03/19/2015 15:55:58.54 OWSTIMER.EXE (0x30D4) 0x7748 SharePoint Foundation Timer 72ae Unexpected Exception stack trace: at
    Microsoft.SharePoint.Administration.SPAnalyticsUsageDefinition.ParseLogFileEntry(String line) at Microsoft.SharePoint.Administration.SPUsageLogImporter.ImportUsageLogFile(SPUsageProvider usageProvider,
    FileInfo logFileInfo) at Microsoft.SharePoint.Administration.SPUsageLogImporter.ImportUsageLogFiles(SPUsageProvider usageProvider, String logDirName, List`1 usageLogFileList) at
    Microsoft.SharePoint.Administration.SPUsageLogImporter.ImportUsageData(SPUsageManager usageManager, DirectoryInfo usageLogDirInfo, String fileFilter) at
    Microsoft.SharePoint.Administration.SPUsageLogImporter.ImportUsageData() at Microsoft.SharePoint.Administration.SPUsageImportJobDefinition.Execute(Guid targetInstanceId) at
    Microsoft.SharePoint.Administration.SPTimerJobInvokeInternal.Invoke(SPJobDefinition jd, Guid targetInstanceId, Boolean isTimerService, Int32& result) 825cf49c-2b6d-a0a5-c45a-88e7d3e4ed5d

    Hi,
    Could you please locate more relevant error information in ULS log to help troubleshooting?
    If you go to Central Administration > Monitoring > Job History, change it to Failed Jobs, check if there are entries for the timer job
    Microsoft SharePoint Foundation Usage Data Import Timer Job. Also try restart the timer job.
    Regards,
    Rebecca Tu
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • It is possible to run a timer job in Office 365 online?

    Hi All,
    Is it possible to run a timer job on 1st of every month  for a list in office 365? I have a requirement that I need to send data of current month via email on 1st of every month. should I use timer job in Office 365?
    Thanks in Advance.

    Hi Darsh,
    There is no option available to run a timer job in SharePoint Online (Office 365), SharePoint timer job option is available only in SharePoint On-premise.
    Microsoft Office 365 provide an alternate of the SharePoint timer Job "Web Jobs" on Azure. You can create Web Job by 2 types
    Web Job as a App on SharePoint
    Web Job as a scheduler
    Read the below articles 
    http://blogs.msdn.com/b/kaevans/archive/2014/03/02/building-a-sharepoint-app-as-a-timer-job.aspx
    http://blogs.msdn.com/b/richard_dizeregas_blog/archive/2014/04/07/sharepoint-timer-jobs-running-as-windows-azure-web-jobs.aspx
    Vivek Jagga 
    My Blog

  • What is safety delta time

    Hi Experts
    Can any one please explain me
    What is safety delta time in terms of delta data source
    Thanks

    Hi,
    Safety Interval Upper Limit of Delta Selection
    This field is used by DataSources that determine their delta generically using a repetitively-increasing field in the extract structure.
    The field contains the discrepancy between the current maximum when the delta or delta init extraction took place and the data that has actually been read.
    Leaving the value blank increases the risk that the system could not extract records arising during extraction.
    Example: A time stamp is used to determine the delta. The time stamp that was last read is 12:00:00. The next delta extraction begins at 12:40:00. In this case, the selection interval is 12:00:00 to 12:40:00. At the end of extraction, the pointer is set to 12:40:00.
    A record - for example, a document- is created at 12:40 but not saved until 12:40. It is not contained in the extracted data but, because of its time stamp, is not extracted the next time either.
    For this reason, the safety margin between read and transferred data must always be larger than the maximum length of time that it takes to create a record for this DataSource (with a time stamp delta), or it must display an interval that is sufficiently large (for determining delta using a serial number).
    Safety Interval Lower Limit
    This field contains the value taken from the highest value of the previous delta extraction to determine the lowest value of the time stamp for the next delta extraction.
    For example: A time stamp is used to determine a delta. The extracted data is master data: The system only transfers after-images that overwrite the status in the BW. Therefore, a record can be extracted into the BW for such data without any problems.
    Taking this into account, the current time stamp can always be used as the upper limit when extracting: The lower limit of the next extraction is not seamlessly joined to the upper limit of the last extraction. Instead, its value is the same as this upper limit minus a safety margin. This safety margin needs to be big enough to contain all values in the extraction which already had a time stamp when the last extraction was carried out but which were not read. Not surprisingly, records can be transferred twice. However, for the reasons above, this is unavoidable.
    these are used to determining the delta in a datasource:
    1. Time stamp - The field is a DEC15 field which always contains the time stamp of the last change to a record in the local time format.
    2. Calendar day - The field is a DATS8 field which always contains the day
    check the thread:
    safety intervels in genric delta extraction.?
    Sriram

  • What is the result of violating the thread safety rule of Swing?

    I needs to know what is the outcome of violating the thread safety rule of swing? memory leak? I have seen code violating the rule but still runs fine. Did anyone know?
    Thanks

    I had violated this rule and sometime it flies and sometimes it does a crash and burn. Most often it can result in a bug seen so rarely that it does not become a concern until the day of product roll-out. Mostly it can result in intermitent GUI anomallies and sometimes total app locks that are hard to intentionally reproduce. All paints and updates are done on the event queue and it is possible to invoke a thread on it saftly.
    I refer you to the tutorial at: http://java.sun.com/docs/books/tutorial/uiswing/mini/threads.html

  • Getting an odd error from a powerpivot timer job, not sure what it means

    Hi Everyone,
    so I am getting this funky error from the PowerPivot Management Dashboard Processing Timer Job:
    The table with ID of '05fa319f-dd29-40d1-b359-417b4d285fa2', Name of
    'DataSources' referenced by the 'Sandbox' cube, does not exist. An error
    occurred when loading the Sandbox cube, from the file, '\\?\C:\Program
    Files\Microsoft SQL
    Server\MSAS10_50.POWERPIVOT\OLAP\Backup\Sandboxes\PowerPivotServiceApplication\8e750a98-850d-4915-bb13-7645fc53adef.11.db\Sandbox.88.cub.xml'.
    Anyone have any idea what this means or how to fix it?
    Best regards, Mike

    Hi,
    According to your post, my understanding is that you got the funky error from the PowerPivot Management Dashboard Processing Timer Job.
    The error means that there is no such file which exists on that location. If the PowerPivot was removed but the target application remained, it was trying to refresh on schedule and was failing.
    In general we can disable the setting to disallow users to use their own credentials by following below steps:
    1. Central Admin->Application Management->Manage Service Applications
    2. Click the PowerPivot service application name. The PowerPivot Management Dashboard appears.
    3. In Actions click Configure service application settings to open the PowerPivot Service Application Settings
    4. In the Data Refresh section clear the “Allow users to enter custom Windows credentials” checkbox.
    For more information, you can refer to:
    PowerPivot – Error while loading sandbox cube
    Thanks,
    Linda Li                
    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]
    Linda Li
    TechNet Community Support

  • What are the thread safety requirements for container implementation?

    I rarely see in the TopLink documentation reference to thread safety requirements and it’s not different for container implementation.
    The default TopLink implementation for:
    - List is Vector
    - Set is HashSet
    - Collection is Vector
    - Map is HashMap
    Half of them are thread safe implementations List/Collection and the other half is not thread safe Set/Map.
    So if I choose my own implementation do I need a thread safe implementation for?
    - List ?
    - Set ?
    - Collection ?
    - Map ?
    Our application is always reading and writing via UOW. So if TopLink synchronize update on client session objects we should be safe with not thread safe implementation for any type; does TopLink synchronize update on client session objects?
    The only thing we are certain is that it is not thread safe to read client session object or read read-only UOW object if they are ever expired or ever refreshed.
    We got stack dump below in an application always reading and writing objects from UOW, so we believe that TopLink doesn’t synchronize correctly when it’s updating the client session objects.
    java.util.ConcurrentModificationException
    at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:449)
    at java.util.AbstractList$Itr.next(AbstractList.java:420)
    at oracle.toplink.internal.queryframework.InterfaceContainerPolicy.next(InterfaceContainerPolicy.java:149)
    at oracle.toplink.internal.queryframework.ContainerPolicy.next(ContainerPolicy.java:460)
    at oracle.toplink.internal.helper.WriteLockManager.traverseRelatedLocks(WriteLockManager.java:140)
    at oracle.toplink.internal.helper.WriteLockManager.acquireLockAndRelatedLocks(WriteLockManager.java:116)
    at oracle.toplink.internal.helper.WriteLockManager.checkAndLockObject(WriteLockManager.java:349)
    at oracle.toplink.internal.helper.WriteLockManager.traverseRelatedLocks(WriteLockManager.java:144)
    at oracle.toplink.internal.helper.WriteLockManager.acquireLockAndRelatedLocks(WriteLockManager.java:116)
    at oracle.toplink.internal.helper.WriteLockManager.checkAndLockObject(WriteLockManager.java:349)
    at oracle.toplink.internal.helper.WriteLockManager.traverseRelatedLocks(WriteLockManager.java:144)
    at oracle.toplink.internal.helper.WriteLockManager.acquireLockAndRelatedLocks(WriteLockManager.java:116)
    at oracle.toplink.internal.helper.WriteLockManager.acquireLocksForClone(WriteLockManager.java:56)
    at oracle.toplink.publicinterface.UnitOfWork.cloneAndRegisterObject(UnitOfWork.java:756)
    at oracle.toplink.publicinterface.UnitOfWork.cloneAndRegisterObject(UnitOfWork.java:714)
    at oracle.toplink.internal.sessions.UnitOfWorkIdentityMapAccessor.getAndCloneCacheKeyFromParent(UnitOfWorkIdentityMapAccessor.java:153)
    at oracle.toplink.internal.sessions.UnitOfWorkIdentityMapAccessor.getFromIdentityMap(UnitOfWorkIdentityMapAccessor.java:99)
    at oracle.toplink.internal.sessions.IdentityMapAccessor.getFromIdentityMap(IdentityMapAccessor.java:265)
    at oracle.toplink.publicinterface.UnitOfWork.registerExistingObject(UnitOfWork.java:3543)
    at oracle.toplink.publicinterface.UnitOfWork.registerExistingObject(UnitOfWork.java:3503)
    at oracle.toplink.queryframework.ObjectLevelReadQuery.registerIndividualResult(ObjectLevelReadQuery.java:1812)
    at oracle.toplink.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneNormally(ObjectBuilder.java:455)
    at oracle.toplink.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:419)
    at oracle.toplink.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:379)
    at oracle.toplink.queryframework.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:455)
    at oracle.toplink.queryframework.ObjectLevelReadQuery.conformIndividualResult(ObjectLevelReadQuery.java:622)
    at oracle.toplink.queryframework.ReadObjectQuery.conformResult(ReadObjectQuery.java:339)
    at oracle.toplink.queryframework.ReadObjectQuery.registerResultInUnitOfWork(ReadObjectQuery.java:604)
    at oracle.toplink.queryframework.ReadObjectQuery.executeObjectLevelReadQuery(ReadObjectQuery.java:421)
    at oracle.toplink.queryframework.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:811)
    at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:620)
    at oracle.toplink.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:779)
    at oracle.toplink.queryframework.ReadObjectQuery.execute(ReadObjectQuery.java:388)
    at oracle.toplink.queryframework.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:836)
    at oracle.toplink.publicinterface.UnitOfWork.internalExecuteQuery(UnitOfWork.java:2604)
    at oracle.toplink.publicinterface.Session.executeQuery(Session.java:993)
    at oracle.toplink.publicinterface.Session.executeQuery(Session.java:950)

    Hi Lionel,
    As a general rule of thumb, the ATI Rage 128 Pro will not support a 20" LCD. That being said, there are reports of it doing just that (possibly the edition that went into the cube).
    I'm not that familiar with the ins and outs of the Cube, so I can't give you authoritative information on it.
    A good place to start looking for answers is:
    http://cubeowner.com/kbase_2/
    Cheers!
    Karl

  • Real time job doesn't receive automatically changes in SAP ECC 6

    Hi Experts,
    <br/>
    <br/>I'm trying to (using Data Integrator) automatically retrieve data from SAP ECC and store it in a local database table. I followed the steps written in this article: http://wiki.sdn.sap.com/wiki/display/BOBJ/Receiving+IDOCs. I'm modifying some records in the Cost Center Master Data (CSKS) and using COSMAS01 as the IDOC in which I'm trying to send the information.
    <br/>
    <br/>All seems to be OK, since I manually sent a Cost Center data row using the /nbd16 transaction, SAP ECC displayed a message telling that an IDOC had been generated. Also, when I checked the IDOC status in BD87 it had status 03, meaning that it had been sent correctly.
    <br/>
    <br/>In Data Services when I clicked on 'View Data' in the local database table that I put in the dataflow I could see the rows that I manually sent from the ECC. However, after truncating the local table, it bothered me that when I tried to send manually a second IDOC with another row from the Cost Center Master Data table, my real-time job didn't receive the request and consequently didn't insert the desired rows. I didn't change anything in the configuration, so my first question to any of you is that if you know what could it be that causes my real-time job to not receive the request from ECC?. I tried making a third try, but at my company they had to shut down the ECC server, so it's going to be a while before I make another try.
    <br/>
    <br/>Now, the REAL question of this post is that after I sent the first IDOC successfully (and before sending manually the second one mentioned earlier), I changed a record in the CSKS table directly in the ECC, hoping that it would automatically generate an COSMAS01 IDOC and send all the data in the table to the Data Integrator. This didn't happen and no IDOC was generated, so do any of you know why the automatic change didn't trigger the sending of the IDOC with the data?
    <br/>
    <br/>As I said before, I made the configuration in ECC and DI following the steps in the link written at the start of the post, and it was tested OK by successfully sending a COSMAS01 IDOC once, manually using bd16.
    <br/>
    <br/>In advance I thank you all for your cooperation. This is my first thread in the SDN forum so also please excuse any mistakes in my english.
    <br/>
    <br/>Best regards...

    You do not need to schedule this job every 10 min.  Why?
    If we can't schedule this job every 10 mints how can I able to retrive the delta records into Queue(RSA7)
    What is your advice I mean how to schedule in order to get the delta?
    Thanks

  • Vector Replacement in Java 1.4 - Is Thread Safety Needed In This Scenario?

    I have a Java 1.4 application that queries Database # 1, and builds custom strings used to create records that are inserted into Database # 2.
    Right now Vectors are used as a container to temporarily hold query output from Database # 1 while building records going into Database # 2, but I want to convert away from this legacy collection type.
    This application does this with a single "worker" thread that is started and monitored by the application main thread. If the main thread detects any exceptions, i.e. a network or any database problem, the application main thread will stop the single worker thread and restart a new single worker thread.
    There are several instances of this application running simultaneously on the same server but accessing different test databases. When put into the production environment this application will run on a separate server and there will be only 1 instance of the application running.
    I have reviewed numerous forums here and Google results and have not found much specific info that would closely apply to my exact design situation. I did not post any code since this is more of a design question than issue with a specific code snippet.
    My question is: In the scenario I described, does thread safety need to be a factor in choosing a new collection type (to replace Vectors) and in building code that accesses this new collection type?

    The several instances of the application are all independent JVMs and can't interact with each other directly at all. So there's no thread safety issue there and there never was. So what does that leave you? You've got a single worker thread using the Vector? There's no thread safety issue there either. The only time you have to think about thread safety is when two threads are trying to use the same object.

  • Urgent question about Thread-safety

    Hi all,
    the new tiger release provides an "isReachable()" method for the "InetAddress" object.
    I've found, this method is not thread-safe (see the source and output below).
    It returns true for all threads, when multiple threads using this method with different adresses are running at a time and one of the addresses is reachable. This happens only on WinXp. Running on Linux, the output is like expected.
    I've tried to report this as a bug. But the gurus answered, taking care of thread safety would be a "programmers task".
    My question is, what can I do, to be thread-safe in my case?
    W.U.
    import java.util.*;
    import java.net.*;
    public class IsReachableTest_1 extends Thread{
        static volatile int inst=1;
        static final String NET_ADDR="192.168.111.";
        int instance=inst++;
        public void run(){
            for(int i=19;i<23;i++){
                try{
                    long start=System.nanoTime();
                    if(InetAddress.getByName(NET_ADDR+i).isReachable(1000))
                        System.out.println(""+instance+"--host found at:"+NET_ADDR+i+"--time:"+(System.nanoTime()-start)/1000000);
                    else
                        System.out.println(""+instance+"--no host at:"+NET_ADDR+i);
                }catch(Exception e){System.out.println(""+instance+"--ERROR "+e.toString());}
            System.out.println(""+instance+"--done.");
        public static void main(String[] args) {
            System.out.println(
                System.getProperty("java.vendor")+" "+
                System.getProperty("java.version")+" running on "+
                System.getProperty("os.name")+" "+
                System.getProperty("os.version"));
            Vector v=new Vector();
            System.out.println("\nTest 1: One after another:");
            for(int i=0;i<10;i++){
                IsReachableTest_1 t;
                t=new IsReachableTest_1();
                t.start();
                try{
                    t.join();
                }catch(Exception e){System.out.println("MAIN1: "+e.toString());}
            System.out.println("\nTest 2: All together:");
            inst=1;
            for(int i=0;i<10;i++){
                IsReachableTest_1 t;
                t=new IsReachableTest_1();
                t.start();
                v.addElement(t);
            for(Iterator i=v.iterator();i.hasNext();)
                try{
                    ((IsReachableTest_1)i.next()).join();
                }catch(Exception e){System.out.println("MAIN2: "+e.toString());}
                System.out.println("\nALL DONE");
    And here is the output, when running on WinXp:
    Sun Microsystems Inc. 1.5.0-beta running on Windows XP 5.1
    Test 1: One after another:
    1--no host at:192.168.111.19
    1--no host at:192.168.111.20
    1--host found at:192.168.111.21--time:2
    1--no host at:192.168.111.22
    1--done.
    2--no host at:192.168.111.19
    2--no host at:192.168.111.20
    2--host found at:192.168.111.21--time:4
    2--no host at:192.168.111.22
    2--done.
    3--no host at:192.168.111.19
    3--no host at:192.168.111.20
    3--host found at:192.168.111.21--time:1
    3--no host at:192.168.111.22
    3--done.
    4--no host at:192.168.111.19
    4--no host at:192.168.111.20
    4--host found at:192.168.111.21--time:1
    4--no host at:192.168.111.22
    4--done.
    5--no host at:192.168.111.19
    5--no host at:192.168.111.20
    5--host found at:192.168.111.21--time:3
    5--no host at:192.168.111.22
    5--done.
    6--no host at:192.168.111.19
    6--no host at:192.168.111.20
    6--host found at:192.168.111.21--time:1
    6--no host at:192.168.111.22
    6--done.
    7--no host at:192.168.111.19
    7--no host at:192.168.111.20
    7--host found at:192.168.111.21--time:1
    7--no host at:192.168.111.22
    7--done.
    8--no host at:192.168.111.19
    8--no host at:192.168.111.20
    8--host found at:192.168.111.21--time:1
    8--no host at:192.168.111.22
    8--done.
    9--no host at:192.168.111.19
    9--no host at:192.168.111.20
    9--host found at:192.168.111.21--time:1
    9--no host at:192.168.111.22
    9--done.
    10--no host at:192.168.111.19
    10--no host at:192.168.111.20
    10--host found at:192.168.111.21--time:1
    10--no host at:192.168.111.22
    10--done.
    Test 2: All together:
    1--no host at:192.168.111.19
    2--no host at:192.168.111.19
    3--no host at:192.168.111.19
    4--no host at:192.168.111.19
    5--no host at:192.168.111.19
    6--no host at:192.168.111.19
    7--no host at:192.168.111.19
    8--no host at:192.168.111.19
    9--no host at:192.168.111.19
    10--no host at:192.168.111.19
    2--no host at:192.168.111.20
    3--no host at:192.168.111.20
    6--host found at:192.168.111.20--time:924 <----- this host does not exist!!
    5--host found at:192.168.111.20--time:961 <----- this host does not exist!!
    10--host found at:192.168.111.20--time:778 <----- this host does not exist!!
    9--host found at:192.168.111.20--time:815 <----- this host does not exist!!
    2--host found at:192.168.111.21--time:37
    7--host found at:192.168.111.20--time:888 <----- this host does not exist!!
    8--host found at:192.168.111.20--time:852 <----- this host does not exist!!
    4--host found at:192.168.111.20--time:997 <----- this host does not exist!!
    1--host found at:192.168.111.20--time:1107 <----- this host does not exist!!
    3--host found at:192.168.111.21--time:38
    6--host found at:192.168.111.21--time:1
    5--host found at:192.168.111.21--time:1
    10--host found at:192.168.111.21--time:2
    2--host found at:192.168.111.22--time:3 <----- this host does not exist!!
    9--host found at:192.168.111.21--time:2
    7--host found at:192.168.111.21--time:1
    4--host found at:192.168.111.21--time:3
    1--host found at:192.168.111.21--time:39
    2--done.
    1--host found at:192.168.111.22--time:5 <----- this host does not exist!!
    1--done.
    10--host found at:192.168.111.22--time:40 <----- this host does not exist!!
    3--host found at:192.168.111.22--time:192 <----- this host does not exist!!
    6--host found at:192.168.111.22--time:75 <----- this host does not exist!!
    8--host found at:192.168.111.21--time:230
    5--host found at:192.168.111.22--time:155 <----- this host does not exist!!
    4--host found at:192.168.111.22--time:78 <----- this host does not exist!!
    9--host found at:192.168.111.22--time:77 <----- this host does not exist!!
    7--host found at:192.168.111.22--time:76 <----- this host does not exist!!
    10--done.
    6--done.
    4--done.
    5--done.
    3--done.
    7--done.
    9--done.
    8--no host at:192.168.111.22
    8--done.
    ALL DONE

    I created this test (it's basically the same as your class):
    import java.util.*;
    import java.net.*;
    public class IsReachableTest_2 implements Runnable {
        private final String[] addresses = new String[] {
             "www.sun.com",
             "129.42.16.99" // www.ibm.com which is not reachable
        public void run(){
            try {
                for (int i = 0; i < addresses.length; i++) {
                    final long start = System.nanoTime();
                    final String address = addresses;
         if (InetAddress.getByName(address).isReachable(5000)) {
         System.out.println(Thread.currentThread().getName() + ": Host found at: " + address +
              " --time: " + (System.nanoTime() - start) / 1000);
         } else System.out.println("no host at: " + address);
    } catch(Exception e){
    e.printStackTrace();
    System.out.println("Thread " + Thread.currentThread().getName() + " DONE");
    public static void main(String[] args) {
    System.out.println(
         System.getProperty("java.vendor") +
         " " +
         System.getProperty("java.version") +
         " running on " +
         System.getProperty("os.name") +
         " " +
         System.getProperty("os.version")
    for (int i = 0; i < 10; i++) {
         final Thread t = new Thread(new IsReachableTest_2(), "THREAD " + (i+1));
         t.start();
    And I get:
    Sun Microsystems Inc. 1.5.0-beta running on Windows 2000 5.0
    THREAD 1: Host found at: www.sun.com --time: 217653
    THREAD 3: Host found at: www.sun.com --time: 214404
    THREAD 6: Host found at: www.sun.com --time: 214900
    THREAD 4: Host found at: www.sun.com --time: 215901
    THREAD 5: Host found at: www.sun.com --time: 216666
    THREAD 10: Host found at: www.sun.com --time: 216620
    THREAD 9: Host found at: www.sun.com --time: 217405
    THREAD 2: Host found at: www.sun.com --time: 220705
    THREAD 7: Host found at: www.sun.com --time: 220845
    THREAD 8: Host found at: www.sun.com --time: 221384
    no host at: 129.42.16.99
    Thread THREAD 4 DONE
    no host at: 129.42.16.99
    Thread THREAD 6 DONE
    no host at: 129.42.16.99
    no host at: 129.42.16.99
    no host at: 129.42.16.99
    no host at: 129.42.16.99
    no host at: 129.42.16.99
    no host at: 129.42.16.99
    no host at: 129.42.16.99
    no host at: 129.42.16.99
    Thread THREAD 5 DONE
    Thread THREAD 10 DONE
    Thread THREAD 9 DONE
    Thread THREAD 7 DONE
    Thread THREAD 3 DONE
    Thread THREAD 1 DONE
    Thread THREAD 2 DONE
    Thread THREAD 8 DONE
    HOWEVER: I was getting some strange results every so often. Results like:
    Sun Microsystems Inc. 1.5.0-beta running on Windows 2000 5.0
    THREAD 3: Host found at: www.sun.com --time: 261132
    THREAD 9: Host found at: www.sun.com --time: 264183
    THREAD 2: Host found at: www.sun.com --time: 266447
    THREAD 6: Host found at: www.sun.com --time: 266596
    THREAD 8: Host found at: www.sun.com --time: 267192
    THREAD 5: Host found at: www.sun.com --time: 268610
    THREAD 4: Host found at: www.sun.com --time: 269849
    THREAD 1: Host found at: www.sun.com --time: 280978
    THREAD 7: Host found at: www.sun.com --time: 272589
    THREAD 10: Host found at: www.sun.com --time: 273162
    THREAD 3: Host found at: 129.42.16.99 --time: 13657
    Thread THREAD 3 DONE
    THREAD 4: Host found at: 129.42.16.99 --time: 4123
    THREAD 2: Host found at: 129.42.16.99 --time: 9439
    THREAD 5: Host found at: 129.42.16.99 --time: 6681
    THREAD 8: Host found at: 129.42.16.99 --time: 7655
    THREAD 6: Host found at: 129.42.16.99 --time: 8627
    THREAD 9: Host found at: 129.42.16.99 --time: 10586
    Thread THREAD 4 DONE
    Thread THREAD 2 DONE
    Thread THREAD 5 DONE
    Thread THREAD 8 DONE
    Thread THREAD 6 DONE
    Thread THREAD 9 DONE
    no host at: 129.42.16.99
    Thread THREAD 7 DONE
    no host at: 129.42.16.99
    no host at: 129.42.16.99
    Thread THREAD 10 DONE
    Thread THREAD 1 DONE
    Usually the first run after I had compiled the class (!?) This isn't a thread safety problem.

  • Reflection objects and thread safety

    Hi,
    I believe that I saw that Field and Method objects are thread-safe (i.e., can safely have methods called against a single object instance concurrently from multiple threads), but am having trouble finding such a description in the JDK javadocs static that fact.
    I'm assuming that all thread-specific 'state' would be managed by the Object target passed to methods like invoke()/get()/set() and not on the actual Field and Method objects themselves. Ideally, i'd like to only have to look up fields and methods only once reflectively, and thereafter just use the same reflection object instances to access their target objects at runtime as a performance optimizations - possibly in different threads and at the same time - without having to pay the cost of looking it up again. I should be able to do that providing Method.invoke() is thread safe. Otherwise, i'd probably be forced to call Class.getMethod() to get a new Method object to use against each object instance, which would be more costly both from a memory standpoint (more Method objects) and a lookup-cost perspective.
    Given that lots of existing performance-critical enterprise infrastructure code, such as OR database APIs, IoC frameworks and J2EE containers use reflection to decouple the generic code from any app specific code (from a compile time perspective) as an alternative to code generation, it's surprising that there's no obvious statement about thread safety in these classes. If I look at the source code for Method, it appears to be thread safe, but I can only get so far with this analysis, as the critical code in Method appears to be implemented using a class named 'sun.reflect.MethodAccessor', whose source I don't have access to.
    I know it's possible to invoke a method against multiple objects by calling Method.invoke() against each of the target objects in question. However, there's no mention as to whether it's safe to use a single Method object instance to invoke a method against multiple target object instances at the same time (i.e., from different threads running in parallel). This would fail, for instance, if the Method object had data members that were used to communicate information between internal calls without any synchronization, as the values might be used by one thread while another was changing them.
    Just to clarify (as i've seen some confusion in other forum discussions on this topic):
    I completely understand that the thread safety of a target object's method (read, small 'm') is entirely dependent upon it's implementation and not the mechanism by which it's invoked - i.e., whether a method is invoked by an explicit compiled-in call against an instance of the target object in some Java source file, or indirectly via Method object-based reflection, is immaterial the the method's thread safety.
    What i'm asking about is the thread safety of the Method.invoke() call itself (read, big 'M'). Same question wrt Field.get()/.set() as well. These calls should be thread-safe if they're stateless wrt the Method and Field object instances that they are invoked against.

    In general, if a Java API is silent about multi-threading, it is intended to be thread-safe. See the javadoc for HashMap for an example of an explicit warning.
    It is true that Java code can have bugs that show up only on unusual implementations of the Java memory model, such as relaxed memory model machines. Most (if not all) implementations of the JDK have been deployed principally on platforms with strong memory models. (Perhaps not coincidentally, those are also the machines that have market share.) There are even bugs found occasionally in the JDK core, so draw your own conclusions about the bug-tail of our software stack on systems with relaxed memory models!
    One of the more likely bugs to run into on highly optimized systems is failure of timely initialization of non-final fields in objects which are shared in an unsynchronized manner. See http://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html#finalRight and related pages. JDK core programmers (at Sun, to my personal knowledge) take care not to write code with such bugs, but application programmers might.
    And, yes, caching your own Method objects is a good idea, if only because their lookup is generally cumbersome and slow. If you are very performance sensitive, you'll end up generating bytecode "shim" between your callers and the desired target methods. I expect that the http://openjdk.java.net/projects/mlvm/ (an openjdk project we are just starting) will provide some relief for this; stay tuned.
    Finally, since Method objects have no state to speak of (except their "accessible" bit, which is an ahead-of-time configuration), it would be really, really surprising if they could create a race condition of some sort. If you expect race conditions in formally stateless data structures, you are certifiably paranoid. (A normal state on some platforms, hopefully not on Java.)
    For more information about method calls, including reflective methods, see my blog post: http://blogs.sun.com/jrose/entry/anatomy_of_a_call_site
    Best wishes...

  • Access Denied in Timer Job

    I have the following code in a timer job. I got "Access Denied" on the last line to access the list although I used "SPSecurity.RunWithElevatedPrivileges". The variable strtemp return a null value. If I runs the same code as a windows
    form application, it works without any problem. The strtemp returns my user name. I will appreciate if someone can let me know what I did wrong. Many thanks.
    namespace UpdateLocationProgram
        public class CustomTimerJob : SPJobDefinition
            //veriable
            int n;
            public const string jobName = "AL_Daily_Proc";
            public CustomTimerJob ():base()
            public CustomTimerJob(string jobName, SPService service, SPServer server, SPJobLockType targetType)
            :base (jobName, service, server, targetType)
            public CustomTimerJob(string jobName, SPWebApplication webApplication)
    : base(jobName, webApplication,
    null, SPJobLockType.Job)
    this.Title = "AL Daily Process";
            public override void Execute(Guid targetInstanceId)
                //connect to local sp
    SPSecurity.RunWithElevatedPrivileges(delegate()
    using (SPSite oSPsite = new SPSite("http://localhost/"))
    using (SPWeb oSPWeb = oSPsite.OpenWeb())
             ///update program code
    string strtemp = oSPWeb.CurrentUser.ToString();
    oSPWeb.AllowUnsafeUpdates = true;
    SPList aList = oSPWeb.Lists["AcctCode"];

    Hi,
    According to your description, my understanding is that you want to get the current user in a timer job.
    "Timerjob runs completely independent from users browsing the site and it runs inside OWSTIMER.EXE".
    "There is no relationship between users browsing the site and what the timerjob does in OWSTIMER.EXE".
    "With other words: the timerjob has no idea about which users (it can be multiple different or also no one at the time the job runs) are currently browsing to the site".
    "So the timerservice cannot get the info about the users accessing the w3wp.exe process".
    Here is a similiar thread for your reference:
    How to get the Current User Credentials
    insdie the sharepoint custom timer job
    Thanks
    Best Regards
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • User Profile Service - User Profile Incremental Synchronization Timer job stuck at 33% Status: Pausing

    User Profile Service - User Profile Incremental Synchronization Progress: 33% Status: Pausing
    It has been almost 15 days.
    Both User Profile Service and User Profile Synchronization Service are in Started state and FIM service also starting 
    I tried clearing sharePoint config cache.
    I also restarted the sharepoint timer service.
    I tried almost everything that is on Internet but nothing helped me.
    Is there any other way to solve the issue as I was struck on production server (ASAP) 
    In synchronization serivce manager status of MOSS_DeltaImport is Inprogress from past 2 days  
    Best Regards.

    Hi,
    Please follow the steps in the link below to clear the configuration cache.
    http://blogs.msdn.com/b/jamesway/archive/2011/05/23/sharepoint-2010-clearing-the-configuration-cache.aspx
    Here is a similar thread for your reference:
    https://social.technet.microsoft.com/Forums/en-US/beaa852c-6f40-428a-b97c-20722864e045/user-profile-service-user-profile-incremental-synchronization-timer-job-stuck-at-88-status?forum=sharepointadminprevious
    Or try to clear the file system cache on all servers in the server farm on which the Windows SharePoint Services Timer service is running. Microsoft has provided a step by step procedure on clearing file system cache from the SharePoint front-end servers
    in this kb article.
    You can also see the ULS logs and check error messages.
    http://sharepointlogviewer.codeplex.com/
    Best Regards
    Dennis Guo
    TechNet Community Support

Maybe you are looking for

  • Problem with brushes in PSE 9

    My brushes in PSE 9 seems to live a life of their own. Eks: I click in my photo with the eraser/dogde/clone and so on.. and the "work" is done in a different place in the picture. Hope you understand my explanation. Does anyone know what to do about

  • Error: "Unable to find a working IR device" in Windows Vista 64-bit, Audigy 4

    I have Audigy 4 Pro with the RM-500 remote that came with it. The remote is not working in Vista 64-bit (Enterprise). It is definitely not a hardware problem because everything works in Windows XP Professional SP3. When I dual boot into Vista, the re

  • Utl_http.request

    Hello every one i m using oracle 10g database and simply try to use this utility utl_http.request so i put the command in sql plus SELECT utl_http.request('http://www.google.com') FROM dual but this showing error ERROR at line 1: ORA-29273: HTTP requ

  • Problems with recovery m

    I finally figured out how to get recovery mode, turns out i was doing it wrong. But I got it and i'm trying to connect it to my pc. Here's the problem, I plug in my USB cable for my MuVo^2 and my LCD screen switches to the transferring screen as if i

  • Run jsp pages that are in WEB-INF folder

    HI I am using struts and I moved my jsp pages from web content to Web-inf folder. Now how do i access them . thanks