Help coderanch get a
new server
by contributing to the fundraiser

Rakesh Am

Greenhorn
+ Follow
since Nov 12, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Rakesh Am

Hi,

My Requirement: I have a METHOD which will take 2 input values. (1)I have to perform initial validations on that values and return to caller.
(2)Same time I have to start a new process with the input values. In the second process it will be calling different Webe services.

I implemented this code by using a after initial validation of inputs, I am starting a thread and return to caller. Inside the thread I am doing the (2) process.
I have written code to implement thread wait, to stop the thread after given break time is reached.

I want to return to caller once initial validation is completed. I want to continue this threa wait should be happen in backgroud.

ISSUE: The METHOD returning to caller after finishing all the process including process(2). It is taking lot of time to return to caller.
Can anybody please tell me how to resolve this issue?

I have written code like...



Please let me know if you need any more information.
Thanks,
Rakesh
14 years ago
I have a scenario like this:
Inside a method, I have to validate the input parameters and also need to start a process independently to do file process. This process will take 4-5 mins. So it should not impact the return value/method.

Can you suggest some ways to implement it?

Virus scan or virus scan method is not throwing any exceptions.

I did stand alone test on Virus scan. It worked properly. When I tried to call thru thread then only I got this issue.
Hi,

I have an issue when i call a third party web service from thread. The example code I have given below.
This code is used to process incoming file. First process method will validate the inputs. then it will do virus scan on the file. for which we have to call a third party webs service.
I am starting the thread because I have to return to caller whether file valid or not and processing is done inside the thread. I have added debug statements inside the thread and virus scan method.
It coming inside the virus scan method, but stops in between without doing virus scan.

Please anybody can help me on this issue.


public class ProcessWS {
public ProcessWS() {
}

public String process(String filename,String srno){

if (filename==null || "".equals(filename) || srno==null || "".equals(srno)){
//log input values are invalid.

return "Invalid input parameters";

}

new Thread(new MyThread(filename,srno)).start();

return "Validations done.Process is started.";


}

class MyThread implements Runnable{

String fn=null;
String srnumber = null;
MyThread(String filename, String srno){
fn = filename;
srnumber = srno;
}

public void run() {
VirusScan vs = new VirusScan();
vs.doVirusScan(fn,srnumber);
// .doVirusScan(fn,srnumber);

}
}

}


Thanks ,
Rakesh
if 'parent' is the last non-daemon thread running (and thus 'child1' and child2' threads are daemon threads), then when 'parent' dies, the JVM starts to shutdown, so the 'child' threads would also die.

---> I have a similar kind of situation, like I am starting a thread from a method. Method will return a value to caller and thread should to rest of the process.
But what happens is thread is starting the process, it stops in between without throwing any exception or error.


example :


public class ThreadTest{

public String testAbc(){

String s ="Hello";
(new Thread(new MyThread())).start();
return s;
}


public class MyThread implements Runnable {
public void run() {
// Process rest ...

}
}
}

Can anybody tell me why it is happening?
What is the solution for this?

Thanks,
Rakesh