I am new to Java.I have a function where I want the function to execute a multithreaded behaviour.The problem is that I will be making the jar without main method inside it.. Just wanted to know that can we have a multithreaded function in Java without a class having main method ?? I have the following code and I want this "myHandler" function to have multithreaded behaviour such that whenever this function gets called,different threads execute it...Can you please help me this code executing multithreaded behaviour?? Thank You
public String myHandler(KinesisEvent kinesisEvent,Context context)
{
int singleRecord=0;
long starttime=System.currentTimeMillis();
//LambdaLogger lambdaLogger=context.getLogger();
for(KinesisEventRecord rec : kinesisEvent.getRecords())
{
singleRecord=0;
System.out.println("Kinesis Record inside is:"+new String(rec.getKinesis().getData().array()));
//count++;
singleRecord++;
// System.out.println(new String(rec.getKinesis().getData().array()));
}
count=count+singleRecord;
long endtime=System.currentTimeMillis();
long totaltime = endtime-starttime;
time=time+totaltime;
System.out.println("Time required to execute single Lambda function for "+singleRecord+" records is"+" :: "+totaltime+" milliseconds");
System.out.println("Total time required to execute Lambda function for "+count+" records is"+" :: "+time+" milliseconds");
return null;
}