Results 1 to 2 of 2
Thread: Multi-threading programing .
- 11-27-2011, 04:24 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 1
- Rep Power
- 0
Multi-threading programing .
HI.
i am writting a very simple programe using muti-threading.
need your advice where should i add the sychronayze if at all..then i call to the main programe with :Java Code:public class CoinFlipping implements Runnable { public void run() { int rundomNumber; int counter=0; for (int i = 0; i <= 1000; i++) { Random rand=new Random(); rundomNumber=rand.nextInt(2); if ( counter >=3 ) { System.out.printf("%s got %d heads in a row.%n", Thread.currentThread().getName(), counter); } if (rundomNumber == 1) counter ++; else counter=0; } } public CoinFlipping(int num){ ExecutorService taskList = Executors.newFixedThreadPool(10); for (int i = 0; i < num; i++) { taskList.execute(this); } }
new ConiFlipping(5)
thanks!Last edited by Norm; 11-27-2011 at 04:34 PM. Reason: added code tags
- 11-27-2011, 04:34 PM #2
Similar Threads
-
Multi-threading issue
By StevenTNorris in forum Advanced JavaReplies: 2Last Post: 10-19-2011, 09:08 PM -
multi-threading problem
By imorio in forum New To JavaReplies: 1Last Post: 04-25-2011, 06:52 PM -
Need Help! Multi-Threading question!
By pinkette in forum New To JavaReplies: 8Last Post: 01-13-2011, 07:08 PM -
Problem in Multi threading.
By Chetans in forum Advanced JavaReplies: 3Last Post: 03-23-2010, 04:42 PM -
question about Multi threading in Java
By fred in forum Advanced JavaReplies: 1Last Post: 07-24-2007, 01:55 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks