0

I am new to Java and wanted to know if I have an xml file such as this:

`<?xml version="1.0" encoding="UTF-8"?>
<Runners>
<Runner Name="Germany">
<RunnersMoveIncrement>70</RunnersMoveIncrement>
<RestPercentage>10</RestPercentage>
</Runner>
<Runner Name="US">
<RunnersMoveIncrement>10</RunnersMoveIncrement>
<RestPercentage>9</RestPercentage>
</Runner>
<Runner Name="UK">
<RunnersMoveIncrement>20</RunnersMoveIncrement>
    <RestPercentage>7</Restpercentage>
    </Runner>
    <Runner Name="CHINA">

<RunnersMoveIncrement>30</RunnersMoveIncrement>
<RestPercentage>15</RestPercentage>
</Runner>
</Runners>'

how do I read this and create threads for this xml file for each of the runner information using the attributes given ? There are so many articles saying so many ways. I am really confused what to do. Can someone give me some idea what to do or a reference as to how to do this?

3
  • 1
    read the xml > create the thread bases on what you readed Commented Nov 18, 2014 at 19:36
  • Thanks Marco. But how do I do that? I am confused with that part. Commented Nov 18, 2014 at 19:39
  • Can someone please guide me with this question? I would highly appreciate it. Commented Nov 18, 2014 at 20:12

1 Answer 1

2

There is several solution to read XML file with Java but I think you have to make the search by yourself. Here comes some trails :

According to me, a good programmer is curious ; don't just ask a question and wait for an answer ;)

A simple way to use threads is :

public class MyThread extends Thread {
    public void run() {
       // What you want to do here ...
    }
}

or ...

public class MyRunnable implements Runnable {
    public void run() {
       // What you want to do here ...
    }
}
Sign up to request clarification or add additional context in comments.

2 Comments

@Fabein I tried reading the XML file but its giving some errors. I am working on resolving them. Thanks for your resources though :) I am still a bit rusty on how do I create threads from what is being read from the XML file
Thanks a ton @Fabein. I figured out what to do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.