multithreading – Java create a thread with parameters


I have a program that counts a word in the text more than once.
I want the loop to be in a separate thread. How can I pass the articls and stringToSearch parameters to the thread or define the global parameters?

public class Main {
    public static void main(String() args)  {
        Scanner s = new Scanner(System.in);
        int numberArticles = s.nextInt();
        ArrayList
articles = new ArrayList<>(); for(int i = 0; i < numberArticles; i++) { String articleName = s.nextLine(); String content = ""; File file = new File(articleName + ".txt"); BufferedReader br; try { br = new BufferedReader(new FileReader(file)); String st; while ((st = br.readLine()) != null) { content += st; } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } articles.add(new Article(articleName, content)); } String stringToSearch = s.nextLine(); MyThread myThread = new MyThread(); myThread.start(); } } public class MyThread extends Thread { public void run(){ for(Article article : articles) { int counter = 0; String() words = article.getContent().split(" "); for (String word : words) { if(word.equals(stringToSearch)) { counter++; } } } } }