Question: Can someone please convert this JAVA code to C code?(only C NOT C++ or C#) public class MultiThreading implements Runnable { @Override public void run()

Can someone please convert this JAVA code to C code?(only C NOT C++ or C#)

public class MultiThreading implements Runnable {

@Override public void run() { // numbers from 1 to 5000 try { for (int i = 1; i <= 5000; i++) { // odd number divisible by 9 if (i % 2 != 0 && i % 9 == 0) { System.out.println(Thread.currentThread().getName() + " : " + i); // sleep thread for 5 seconds Thread.sleep(5000); } }

} catch (InterruptedException e) { e.printStackTrace(); }

}

public static void main(String[] args) { // note: in order to create 3 threads, three objects must be created. single // object cannot be used // create object MultiThreading obj1 = new MultiThreading(); // create threads Thread ThreadOne = new Thread(obj1, "ThreadOne");

// create object MultiThreading obj2 = new MultiThreading(); // create threads Thread ThreadTwo = new Thread(obj2, "ThreadTwo");

// create object MultiThreading obj3 = new MultiThreading(); // create threads Thread ThreadThree = new Thread(obj3, "ThreadThree");

// start all threads ThreadOne.start(); ThreadTwo.start(); ThreadThree.start();

}

}

------------------------------------------------------------------

output:

In this program each thread will print each odd number divisible by 9 and sleep for 5 seconds.

The position of sleep(5000) can be changed

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!