Win a copy of Terraform in Action this week in the Cloud forum!

Raihan Jamal

Ranch Hand
+ Follow
since Mar 23, 2010
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Raihan Jamal

I am working on a project in which I have three box (as of now) and each box will have some color of balls

So I am storing them in a Map of String and List of String as mention below.

Data in the above map is like this -


Basis on the above input, I need to return a mapping which will be List<Map<String, String>>, let's say for above input, below mapping would be return as an output -

Here if you see, each row has alternate color of balls for each box - meaning blue for box1, red for box2, orange for box3 in first row. I cannot have same color of balls in each row. So this combination is not possible as it has same color of balls for two boxes in one row.

And also, in the second row, I won't use those balls which have been used in the first row for that box. In second row, box1 has red why? because blue was already used in the first row for box1 and box3 has blue and no box2 in second row.

The output combination is getting generated basis on the input being passed as shown above.

I started with the below code -

Below is my method in which the crux of logic should be there

Below algorithm might work but still not sure how should I fit this in the code -

- sort the boxes by the number of balls they have in it (ascending, from the smallest to the largest box).
- while there are colors left
- loop over the sorted list of boxes
- in each iteration pick a color from the box (if there is one left), that is not already picked in the current iteration (of the while loop)

This is what I have tried but this only works for when number of balls is same in each box-

7 years ago
I am using annotation based validation for one of my forms and I am not able to show any errors using the **form:errors tag** I used in JSP file. When I try to debug it, I found out that the BindingResult does not show any errors as well but I am leaving the textbox empty to test the validation. Any pointers are greatly appreciated why I am not able to validate it.

Below is my Controller Class

Below is my model class-

Below is my requestform.jsp file

Below is my context.xml file

Can anyone tell me what wrong I am doing here?
8 years ago
This is my main class in which I am trying to create a `ThreadPoolExecutor` with the given size.

Problem Statement:-

Previously I was using the concept of LinkedList here to pass the unique ID everytime and release that id for reuse by the threads. But somehow that was not working properly when I tested that out.

As I need-

Each thread should use unique ID between 1 and 500 and program has to run for 60 minutes or more, So in that 60 minutes it is possible that all the ID's will get finished so I need to reuse those ID's again.

So Now I started using the concept of ArrayBlockingQueue which I tested it out slightly and it was looking good to me. But just wanted to make sure, I am doing right and this program will not crash in any of the case, I needed some help.

Two Questions:-

1) Is there any other better approach than this considering my above scenario?
2) Secondly is there any loop hole in my program considering my above scenario as each thread needs to use UNIQUE ID everytime and release those ID's for reuse?

9 years ago
This is my Below code which only draws one Circle around Current Location as the center. I need to draw a Circle within Circle around the current location on the google map. Total circle should be 5. Radius of each circle should be like this-

Below code works fine to create only one circle by taking the current location as the center. But how can I draw other circles with the above specification.

I am having hard time making other circles by taking current location as the center. R.drawable.current_user is the current location
9 years ago
Yes. That is right.
9 years ago
I want unique random number between 0 and 1001. But by using Random it will not be more efficient in this case I guess.
9 years ago
Ok. Now it makes sense, So code should be something like the below after making changes If I need to generate unique random number between 0 and 1001?

9 years ago
I think so it is ok. As the List contains element starting from 1 to 1000 so I can retrieve the element from 1000 index size right?
9 years ago
This is my below code in which I am trying to generate random unique number between 0 and 1001 and pass that number to some method. But this code gives me index out of bound exception. I am not sure why it is giving me that exception. Can anyone suggest me why is it happening?

9 years ago
I have my Batch Application Program, in which I am using ThreadPoolExecutor in my Batch Application Program. So as soon as it hits the-

line in my Batch Application program, I always get this below error in my Batch Application Program. And I am not able to ShutDown my own Executor Service. Can anyone suggest me how should I overcome this error.

. Below is the full stacktrace

How can I shut down my own ExecutorService under SecurityManager.

I am using Windows7 and Java6-IBM(java6-ibm-sr4ifx3-2009-06-22).

I am trying to shut down like this-

9 years ago
I know how can I relate this if there are three tasks. For example if there are three tasks then I can have something like this-

if(R>1 && R<percentageCalls.get(0)) {

} else if(R>(percentageCalls.get(0) + 1) && R<(percentageCalls.get(0) + percentageCalls.get(1))) {

} else if(R>(percentageCalls.get(0) + percentageCalls.get(1)) && R<(percentageCalls.get(0) + percentageCalls.get(1) + percentageCalls.get(2))) {


Where R is random number and percentageCalls is the ArrayList of Integer where I have stored all the percentage. But what I am most worried is that if we have suppose N tasks then how should I move.
9 years ago
Yes that's what my questions is, more specifically it is like-

Here A + B + C + . . . . + N should be 100%. Can anyone give me some sort of code snippet that will work on my config file. Any help will be appreciated.
9 years ago
How can I make this more configurable in the code as the percentage number will keep on changing in the config file, so based on the percentage in the config file how can I make this configurable for all the situations. But for this case I can hardcode the conditions but in general case how can I make this configurable. Any code snippet will be appreciated.
9 years ago
So Suppose if I am generating random number between 1 and 100.
And if the number is between 1 and 75, I will execute CommandA, so that means it will execute CommandA 75% of the time?
And if the number is between 76 and 89, I will execute CommandB, so that means it will execute CommandB 15% of the time?
And same with CommandC?
9 years ago
This is my Config File(Test.txt)

The above Config File have some type of weighing to the Commands (execute CommandA 75% of the time, execute CommandB 15% of the time and execute Command C 10% of the time. Total weighing should add up to 100%.

Code that I wrote:-
I wrote a multithreading program in which I am reading the files line by line but not sure how should I do the above question in which this much percentage of random calls go to CommandA, and this much percentage of random calls go to CommandB and same with CommandC.

9 years ago