Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8297535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:27:07+00:00 2026-06-08T15:27:07+00:00

I wrote a java program to test the capabilities of processors by running an

  • 0

I wrote a java program to test the capabilities of processors by running an amount of calculations and then matching it up against my friends computers.

However when I run the program, it doesn’t use 100% of the processor. The processing power goes from 1-2% to 27% and the RAM stays at 34%.

Is this just the way java or processors work? or is it something with my code? Here’s the class that handles the calculation(Note: I’m still learning how to program, and I’m interested in the way the software interacts with the hardware):

import javax.swing.JTextPane;

public class Main {

    static int numberToCalculate = 100;
    static int otherNumberToCalculate = 50;
    static String typeOfCalculation = "all";
    static int calculated;
    static int calculations = 10000000;

    public static void calculate(JTextPane j, JTextPane j2) {
        long time = System.currentTimeMillis();
        for(int i = 0; i <= calculations; i++) {

            switch(typeOfCalculation) {
            case "Divide":
                calculated = numberToCalculate / otherNumberToCalculate;
                break;

            case "Multiply":
                calculated = numberToCalculate * otherNumberToCalculate;
                break;

            case "Plus":
                calculated = numberToCalculate + otherNumberToCalculate;
                break;

            case "Minus":
                calculated = numberToCalculate - otherNumberToCalculate;
                break;

            case "All":
                calculated = numberToCalculate / otherNumberToCalculate;
                calculated = calculated * otherNumberToCalculate;
                calculated = calculated + otherNumberToCalculate;
                calculated = calculated - otherNumberToCalculate;
                break;

            default:
                Test.UpdateText(j, "Error, please pick type of calculation.");
                Test.UpdateText(j2, "Error, please pick type of calculation.");
                break;
            }
            if(i == calculations) {
                Test.UpdateText(j, "Milliseconds: " + (System.currentTimeMillis() - time));
                Test.UpdateText(j2, "Result: " + calculated);
            }
        }
    }

    public static void main(String [] args)
    {
        Test.window();
    }

}

And here’s a picture of the output: https://i.stack.imgur.com/lH1VA.png

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T15:27:08+00:00Added an answer on June 8, 2026 at 3:27 pm

    If you’re on a multi-processor machine, you’re only going to be maxing out one processor with this code. I’m going to go out on a limb and guess that you have 4 processors (or 2 with hyperthreading). That would explain why you’re only getting 27% utilization.

    You’ll need to spin up extra threads doing calculations as well if you want to truly max out all of the cores in your system.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote this program in Java public class Why { public static void test()
so I wrote a Java program to change the IP of a machine. public
I'm trying to convert an old Delphi program I wrote into Java to compile
I wrote a program in java that rolls a die and records the total
I wrote a simple program in java web forms but i am receiving the
I have wrote the code below which was taken from Java How to program
I'm learning to work with lucene. I wrote a simple program to test lucene
I wrote a simple hello world program to test the JDK installation. I can
I wrote a simple program with java swing which suppose to start another thread
I wrote a java program injecting spring Mail following instructions here - Spring EMail

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.