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

  • SEARCH
  • Home
  • 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 8614291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:05:16+00:00 2026-06-12T05:05:16+00:00

I am developing desktop app in Java 7. I have here a situation. At

  • 0

I am developing desktop app in Java 7. I have here a situation. At the method below

private synchronized void decryptMessage
    (CopyOnWriteArrayList<Integer> possibleKeys, ArrayList<Integer> cipherDigits)
{
    // apply opposite shift algorithm:
    ArrayList<Integer> textDigits = shiftCipher(possibleKeys, cipherDigits);

    // count CHI squared statistics:
    double chi = countCHIstatistics(textDigits);

    if(chi < edgeCHI) // if the value of IOC is greater or equal than that
    {
        System.err.println(chi + " " + possibleKeys + " +");
        key = possibleKeys; // store most suitable key
        edgeCHI = chi;
    }       
}

I count the value called ‘chi’ and based on that if ‘chi’ is less than ‘edgeCHI’ value I save the key at instance variable. That method is invoked by some threads, so I enforce synchronization.

When all the threads complete the program continues to execute by passing control to a method which controls the sequence of operations. Then this line has been executed at that method:

System.err.println(edgeCHI+" "+key+" -"); 

It prints correct value of ‘chi’, as has been printed the last value of ‘chi’ at decryptMessage method, but the value of key is different. The ‘decryptMessage’ method has been invoked by threads which generate key values.

I store the key value as global variable
private volatile CopyOnWriteArrayList<Integer> key = null; // stores the most suitable key for decryption.
Why do I have two different key values? The values itself are not important. The matter is that the value of key printed at the last call at ‘decryptMessage’ method (when chi < edgeCHI) must match the one printed at the method which controls the flow of operations.
This is how you create threads:

for(int y = 0; y < mostOccuringL.length; y++){// iterate through the five most frequent letters
                for(int i = (y + 1); i < mostOccuringL.length; i++ ){//perform letter combinations
                    int [] combinations = new int[2];
                    combinations[0] = y;
                    combinations [1] = i;                   
                    new KeyMembers(""+y+":"+i ,combinations, keywords, intKeyIndex, cipherDigits).t.join();
                }
            }   

Within run method you invoke decryptMesssage method in order to identify most feasible decryption key.
I have been trying to figure out what is the prob for two days, but I don’t get it.
Suggestions?

  • 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-12T05:05:17+00:00Added an answer on June 12, 2026 at 5:05 am

    Solution has been found. I just changed CopyOnWriteArrayList data type into ArrayList at the point where field variable gets correct key. It works as expected now.

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

Sidebar

Related Questions

I am developing a desktop app using Java and Swing Application Framework. I have
I am developing a Java Desktop Application . This app needs a configuration to
I have been developing an app for weeks on a desktop computer. I have
I am developing a Java Desktop Application but have some confusions in choosing a
I am developing a new Java Desktop app. Something like a media player. I
I am about to start developing a small Java desktop app. The app is
I am developing a WPF desktop app for a small business. It will have
I'm developing a desktop Mac OS X App that saves its very simple data
We have a dilemma; developing desktop application using Matisse or Jigloo.. Matisse has this
I am developing a Java Desktop Application and want a light database that can

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.