KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
How can i order threads in the order they were instantiated.e.g. how can i make the below program print the numbers 1...10 in order. public class ThreadOrdering { public static void main(String[] args) { class MyRunnable implements Runnable{ private final int threadnumber; MyRunnable(int threadnumber){ this.threadnumber = threadnumber; } public void run() { System.out.println(threadnumber); } } for(int i=1; i<=10; i++){ new Thread(new MyRunnable(i)).start(); } } }
Tags (comma-separated)
Save Edits
Cancel