I want to show the progress of the two thread . It works wonderful with one, but when I am trying to add another one, something is going wrong.
I'm trying:
ProgressHandle ph = ProgressHandleFactory.createHandle("MyTask1");
ph.start();
ph.finish();
ProgressHandle ph2 = ProgressHandleFactory.createHandle("MyTask2");
ph2.start();
ph2.finish();
What I need to do is to show progress of 2 executing tasks like in netbeans IDE.
You should execute your code in a Runnable
thread. eg:
RequestProcessor RP = new RequestProcessor("my RP");
final ProgressHandle ph = ProgressHandleFactory.createHandle("my task 1");
task = RP.create(new Runnable() {
@Override
public void run() {
int workunits = 100;
ph.start(workunits);
for(int i = 0; i < workunits; i++){
//do some work
ph.progress(i);
}
ph.finish();
}
});
task.schedule(0);
adding more tasks via RP
is easy, you can use also RP.post(runnable)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.