Results 1 to 5 of 5
  1. #1
    kgcan2000 is offline Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    Default about System: currentTimeMillis()

    hello,
    i am new in java,
    i wrote a java program, my program is multiplication of two big matrixes and i used 10, 50 ,200, 1000 treads in it to execute. but when i computed the endtime-starttime of my program for each number of threads, i had increasing numbers according to the increasing number of threads.
    i used "currentTimeMillis()".
    for example:
    10 threads==> 266
    200 threads ==> 2484
    1000 threads ==> 12549
    why did i meet this result,
    my computer in not multicore and i was expecting decreasing numbers according to increasing number of threads?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

  3. #3
    kgcan2000 is offline Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    Default

    first, thank you for you interested my problem,
    i dont know if it is true, but i had an expectation that if we used multiple threats, the computation would finished earier because we divided the jop to parts, and
    i used:

    Java Code:
      " long startTime = System.currentTimeMillis();
               mainclass ext=new mainclass();
               ext.islemler(); 
        long endTime = System.currentTimeMillis();
        System.out.println(endTime-startTime); "

    in detail,

    islemler is:

    Java Code:
    public void islemler(){
        	"for(int x=1;x<=1000 ;x++)
    /*    1,10,50,100,200,500,1000==> thread     number, we can change it if we want to do it by 1,10,50,100,200,500,1000 threads by replacing these numbers, here now there is "1000".*/
        	{      ThreadClass t;Thread a; 
        		     t=new ThreadClass(x,1000);
        			 a=new Thread(t);
        			 a.start();
        			
        	 }
    Last edited by Fubarable; 04-02-2011 at 07:32 PM. Reason: code tags added

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Multi-threading per se cannot speed up computer processing, since each thread shares a bit of processor time and will slow the other down. The exception to this is with a multiple processor environment if the problem can be split into parallel non-dependent processes, and even then, there's no guarantee that Java and the OS will run things on different processors.

  5. #5
    kgcan2000 is offline Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

Similar Threads

  1. What is the hiring system
    By ruchira_sandanayaka in forum Java Applets
    Replies: 1
    Last Post: 04-03-2010, 03:25 AM
  2. Replies: 3
    Last Post: 02-07-2010, 08:34 PM
  3. Password System help
    By quickfingers in forum New To Java
    Replies: 1
    Last Post: 06-23-2008, 06:18 PM
  4. System.out.println
    By sunjavaboy in forum Advanced Java
    Replies: 3
    Last Post: 03-22-2008, 01:30 AM
  5. System.getProperties(key)
    By diRisig in forum New To Java
    Replies: 1
    Last Post: 02-06-2008, 12:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •