dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Finding Number of Cores in Java

  1. #1
    Join Date
    Dec 2018
    Posts
    8

    Finding Number of Cores in Java

    How can I find the number of cores available to my application from within Java code?

  2. #2
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,823

    Re: Finding Number of Cores in Java

    Look at the Runtime class's methods.
    Norm

  3. #3
    Join Date
    Dec 2018
    Posts
    8

    Re: Finding Number of Cores in Java

    Finding Number of Cores in Java

    int cores = Runtime.getRuntime().availableProcessors();

    If cores is less than one, either your processor is about to die, or your JVM has a serious bug in it, or the universe is about to blow up.
    Last edited by 2kaud; December 17th, 2018 at 08:17 AM. Reason: removed site advert

  4. #4
    Join Date
    Feb 2017
    Posts
    389

    Re: Finding Number of Cores in Java

    Quote Originally Posted by kadammanali987 View Post
    If cores is less than one, either your processor is about to die, or your JVM has a serious bug in it, or the universe is about to blow up.
    Or a divine power is giving you a sign not to make your application dependent on the number of cores.

  5. #5
    Join Date
    Feb 2017
    Posts
    389

    Re: Finding Number of Cores in Java

    Quote Originally Posted by wolle View Post
    Or a divine power is giving you a sign not to make your application dependent on the number of cores.
    Again, why are you reposting old threads from StackOverflow. This is the third one now.

    https://stackoverflow.com/questions/...-cores-in-java

Tags for this Thread

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)