I'm familiar with threading in python and ruby, but I'm a bit lost as to how to carry it out with Java.

The examples i've seen tell me something about a `Runnable` interface, but I'm not quite sure how that works into what I'm trying to do.

Basically I'm trying to refactor a web scraper to use threading instead (so each URL is done by a new thread) to speed it up.

In ruby, I would simply do a `Thread.new` but I'm not exactly sure as to how to (correctly!) implement this in java.

Can anyone guide me on how to do this? :) It will be greatly appreciated!

I've commented the block which I want to outsource below :)

```
public class Collecting_Description 
{
    @SuppressWarnings("empty-statement")
    public static void main(String[] args) throws FileNotFoundException, IOException
    {
        FileReader fr = new FileReader("plugin_list.txt");
        BufferedReader br = new BufferedReader(fr);
        FileWriter fw = new FileWriter("DescriptionOutPut.txt",true);
        BufferedWriter bw = new BufferedWriter (fw);

        List<String> listOfPlugins = new ArrayList <String>();
        listOfPlugins = Collecting_Description.addToListOfPlugins(br, listOfPlugins);

        // THIS BLOCK TO BE REFACTORED TO USE THREADING
        for (int i=0;i<listOfPlugins.size();i++)
        {
             System.out.println(listOfPlugins.get(i) + " ("+ i + ") in progress");
             String astemp = listOfPlugins.get(i).replace("", "");
             try
             {
                Document doc = Jsoup.connect("https://wordpress.org/plugins/"+ URLDecoder.decode(astemp, "UTF-8")).get();
                Elements description = doc.select("div#tab-description");
                String context = null;
                for(int j=0; j<description.size(); j++)
                {
                    context = context + description.get(j).text();
                }
                bw.write("[PluginName:{"+ astemp +"},"+ "Description:{"+ context + "}]\n");
             }
             catch(Exception e)
             {

             }
        }

        bw.close();
    }

    public static List addToListOfPlugins(BufferedReader br,List listOfPlugins) throws IOException { 
        String line;
        while((line = br.readLine())!=null) {
           listOfPlugins.add(line);
        }

        return listOfPlugins;
    }
}

```

EDIT: Updated Code

```
package htmlparser.loop;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.List;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

public class Collecting_Description {
     @SuppressWarnings("empty-statement")
     public static void main(String[] args) throws FileNotFoundException, IOException {
        FileReader fr = new FileReader("plugin_list.txt");
    BufferedReader br = new BufferedReader(fr);
        FileWriter fw = new FileWriter("DescriptionOutPut.txt",true);
        BufferedWriter bw = new BufferedWriter (fw);

    List<String> listOfPlugins = new ArrayList <String>();
        listOfPlugins = Collecting_Description.addToListOfPlugins(br, listOfPlugins);

        // THIS BLOCK TO BE REFACTORED TO USE THREADING
        for (int i=0;i<listOfPlugins.size();i++) {
            String scrapedHTML = Collecting_Description.scrapeURL(listOfPlugins, i);
            // write to file
            bw.write(scrapedHTML);
        }
        bw.close();
     }

     public static List<String> addToListOfPlugins(BufferedReader br,List<String> listOfPlugins) throws IOException { 
        String line;
        while((line = br.readLine())!=null) {
           listOfPlugins.add(line);
    }
        return listOfPlugins;
     }
     public static String scrapeURL(List<String> listOfPlugins, int i){
        System.out.println(listOfPlugins.get(i) + " ("+ i + ") in progress");
        String pluginName = listOfPlugins.get(i).replace("", "");
        try {
           Document doc = Jsoup.connect("https://wordpress.org/plugins/"+ URLDecoder.decode(pluginName, "UTF-8")).get();
           Elements description = doc.select("div#tab-description");
           String context = null;
           for(int j=0; j<description.size(); j++) {
               context = context + description.get(j).text();
           }
           String returnString = "[PluginName:{"+ pluginName +"},"+ "Description:{"+ context + "}]\n";
           return returnString;
        }
        catch(Exception e){
            System.out.println(e);
        }
        return "Error";
     }
}

```