Question: Create a class named LongTaskthat extends the Threadclasscontaining the following:Private instance variablessharedData(of type SharedResults), inputData(of type StringBuffer)and target(of type char) Constructor thattakes three arguments and

Create a class named LongTaskthat extends the Threadclasscontaining the following:Private instance variablessharedData(of type SharedResults), inputData(of type StringBuffer)and target(of type char) Constructor thattakes three arguments and stores them in the instance variables.It should alsocreate a name for this thread as Thread_.In the run()method, use a loop overthe characters ininputDataand count the number of occurrences of target. After the loop is done, create a ResultsEntryobject with this count and the target character, and invoke the addToResults()methodof results

this is the code

public class LongTask extends Thread { //Create private instance variables SharedData, inputData, target private SharedResults sharedData; private StringBuffer inputData; private char target; //create constructor with three arguments public LongTask(SharedResults sharedData, StringBuffer inputData, char target) { this.sharedData = sharedData; this.inputData = inputData; this.target = target; //it should also create a name for this thread as Thread_; } //create run() method public void run() { /*Create for loop for looping over the characters in inputData and count the number of occurrences of target * * */ for (int i =1; i

} I stuck at the for loop I didn't know what to do and what is this it should also create a name for this thread as thread_

here I lost and I couldn't complete it?? any help??

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!