ConcurrentHashMap Can Be Used In Readwrite Lock?
Jul 25, 2014ConcurrentHashMap can be used in Readwrite Lock..
View RepliesConcurrentHashMap can be used in Readwrite Lock..
View RepliesMy code is long so I will try to explain this. I have a GUI application which gets two dates from a user via multiple combo boxes (month/day/year for each, so 6 total). The assembly and processing of these dates (including the days changing based on the month) is correct.
That said, however, when interacting with the program and changing the dates back-and-fourth on the frame, the 'days' combo boxes occasionally lock to one another. For instance, if you select 5 in one, 5 mimics in the other and this cannot be undone.
These are the last relevant bits I believe before the 'SUBMIT' button is clicked and it is all processed.
Controller ... (same set-up for the departure date)
Java Code:
// MONTH COMBO BOX LISTENER -- ARRIVAL
class ArriveCBListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
// Arrive Dates
[Code] .....
I'm suppose to read the following code and devise a program that can break the lock.
public class InsecurePasswordLock {
private char[] secret;
private boolean unlocked;
public InsecurePasswordLock() {
// secrets are usually 30 to 50 upper case characters long
// but here's a hard coded example one
secret = "ASECRETTHATYOUWILLNOTGUESSTODAY".toCharArray();
[Code]....
So, I believe that I can try various password lengths until I get a return from open that !=-1. But I'm not sure how to implement this. This is what I have so far to get the length:
public char[] breakLock(InsecurePasswordLock lock) {
int checkCount=1;
int length=0;
while(checkCount!=-1){
for(int i=0;i<=25;i++){
char[] key = new char[i];
if(InsecurePasswordLock.open(key)!=-1){ // I get a fault at this line for calling a static method
length=i;
checkCount=-1;
}
}
}
I get the error:
Cannot make a static reference to the non-static method open(char[]) from the type InsecurePasswordLock..
How can I keep querying the open method to get my length??
Which methods can be used to lock keyboard and mouse inputs using java??
View Replies View Relatedhow can I provide a lock to a CSV file while creating the CSV file using java application and how to restrict the user to open CSV file manually instead of opening the file using java application(Swings and Hibernate). That means instead of opening the file manually the user has to use java application to open that CSV file.
View Replies View Related I need to use a counter to keep track of user's input. In this class I am trying to create a combination lock that takes three strings. In the tester class the user inserts three strings and both are compared to see if users input matches correct combination. I have no errors only problem is the setPosition method. My output is always false.
public class CombinationLock {
private String first;
private String second;
private String third;
private String firstGuess;
private String secondGuess;
private String thirdGuess;
private boolean open;
private int counter;
[code]....
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
public class tree_lock_test{
int total_instances;
int thread_instances = 0;
int N;
[Code] .....
this is compiled with another Peterson class which has implemeted peterson lock for two threads ...