How can I make my thread to allow Long-running operations?
Please help.
I was getting the following exception. What should I do to make my thread acceptable by ThreadCheck's checkLongOpsAllowed method.
Thanks,
Weiping
==========================================================
java.lang.IllegalStateException: Long-running operations prohibited on this thread
at com.ibm.team.repository.client.util.ThreadCheck.checkLongOpsAllowed(ThreadCheck.java:115)
at com.ibm.team.repository.client.internal.ServiceInterfaceProxy.invoke(ServiceInterfaceProxy.java:78)
at $Proxy9.save(Unknown Source)
at com.ibm.rmc.jazz.uma.convert.impl.UmaAdaptorMgrImpl03$1.visit(UmaAdaptorMgrImpl03.java:338)
at com.ibm.rmc.jazz.uma.convert.impl.RmcJazzObjectMgr.visitedBy(RmcJazzObjectMgr.java:69)
at com.ibm.rmc.jazz.uma.convert.impl.UmaAdaptorMgrImpl03$2.run(UmaAdaptorMgrImpl03.java:353)
at java.lang.Thread.run(Thread.java:801)
at com.ibm.rmc.jazz.uma.convert.impl.UmaAdaptorMgrImpl03.saveMethodLibrary(UmaAdaptorMgrImpl03.java:361)
at com.ibm.rmc.jazz.uma.library.JazzResourceSetImpl.save(JazzResourceSetImpl.java:53)
at
I was getting the following exception. What should I do to make my thread acceptable by ThreadCheck's checkLongOpsAllowed method.
Thanks,
Weiping
==========================================================
java.lang.IllegalStateException: Long-running operations prohibited on this thread
at com.ibm.team.repository.client.util.ThreadCheck.checkLongOpsAllowed(ThreadCheck.java:115)
at com.ibm.team.repository.client.internal.ServiceInterfaceProxy.invoke(ServiceInterfaceProxy.java:78)
at $Proxy9.save(Unknown Source)
at com.ibm.rmc.jazz.uma.convert.impl.UmaAdaptorMgrImpl03$1.visit(UmaAdaptorMgrImpl03.java:338)
at com.ibm.rmc.jazz.uma.convert.impl.RmcJazzObjectMgr.visitedBy(RmcJazzObjectMgr.java:69)
at com.ibm.rmc.jazz.uma.convert.impl.UmaAdaptorMgrImpl03$2.run(UmaAdaptorMgrImpl03.java:353)
at java.lang.Thread.run(Thread.java:801)
at com.ibm.rmc.jazz.uma.convert.impl.UmaAdaptorMgrImpl03.saveMethodLibrary(UmaAdaptorMgrImpl03.java:361)
at com.ibm.rmc.jazz.uma.library.JazzResourceSetImpl.save(JazzResourceSetImpl.java:53)
at
Accepted answer
Typically this exception indicates that you are on the UI thread. It is
trying to warn you that calling a long running operation (like making
a network call) on the UI thread will lock up the UI.
Try using a org.eclipse.core.runtime.jobs.Job to put your network call
on a non-UI thread. It would look something like this:
Job job = new Job("my job") {
protected abstract IStatus run(IProgressMonitor monitor) {
// your longop call here
}
};
job.schedule(); // start the job
wlu wrote:
trying to warn you that calling a long running operation (like making
a network call) on the UI thread will lock up the UI.
Try using a org.eclipse.core.runtime.jobs.Job to put your network call
on a non-UI thread. It would look something like this:
Job job = new Job("my job") {
protected abstract IStatus run(IProgressMonitor monitor) {
// your longop call here
}
};
job.schedule(); // start the job
wlu wrote:
Please help.
I was getting the following exception. What should I do to make my
thread acceptable by ThreadCheck's checkLongOpsAllowed method.
Thanks,
Weiping
==========================================================
java.lang.IllegalStateException: Long-running operations prohibited on
this thread
at
com.ibm.team.repository.client.util.ThreadCheck.checkLongOpsAllowed(ThreadCheck.java:115)
5 other answers
Thank both of you. I tried using the Job scheduling approach, and it worked fine.
Comments
I ran into the same problem and then used the Job scheduling approach. But what I have noticed is that this approach avoids the exception only for the first time. But if I try to do the same thing again (my op was actually to update the work item status), then I get the same illegal state exception "Long-running operations prohibited on this thread" for the Job thread. What can I do here?