khaled abu shamat

Greenhorn
+ Follow
since Apr 08, 2017
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by khaled abu shamat

Dave Tolls wrote:Couldn't you just create a new PropertiesValue in each new thread?
It doesn't look like you need to store any results in it from the various runs.



What i have is a class that has a singleton design pattern to create a new instance of the strategy
3 years ago

Paul Clapham wrote:

khaled abu shamat wrote:Paul my validatePatternAndCheckCase method is synchronised



I see. And you did that because if two threads accessed the method at the same time then it would cause problems?



I will be a problem as long as the files that being passrd will get a different strategy but if they will do so that will be a problem if you like i can show more code
3 years ago

Paul Clapham wrote:I think perhaps if the work the threads are doing took a lot longer, you might get them running at the same time. Maybe put some Thread.sleep calls in there to slow them down? I don't see anything in there which would prevent those threads from starting and doing their work right away.

my validatePatternAndCheckCase methos is synchronised
3 years ago
Paul my validatePatternAndCheckCase method is synchronised
3 years ago
I have the following code, which is used to watch a directory and on a creation of a file a thread starts, it should read a CSV file and save the values of it in an object, after that I use the data saved in the object to sort the data from the CSV file in new directory depending on some strategies defined in a config.proprties file, when I paste some files in the directory that is being watched, it gets processed one after another, but what I want is to make them run at the same time unless I have more than one file that will use the same strategy can someone advice what am I doing wrong?

Here is my Watcher class:


And here is the class that used to read the property file and match it with file that have been created:

And here is my strategy implementation class:

When I run the code I get the following result:

Thread Name = Thread-2
Thread Name = Thread-2
Thread Name = Thread-2
Thread Name = Thread-2
Thread Name = Thread-2
Thread Name = Thread-5
Thread Name = Thread-5
Thread Name = Thread-5
Thread Name = Thread-5
Thread Name = Thread-5
Thread Name = Thread-4
Thread Name = Thread-4
Thread Name = Thread-4
Thread Name = Thread-4
Thread Name = Thread-4
Thread Name = Thread-3
Thread Name = Thread-3
Thread Name = Thread-3
Thread Name = Thread-3
Thread Name = Thread-3
3 years ago
I had a task to do some statistics by implementing two interfaces one to which defines a key and a value for the statistic and the other to define and visit a statistic collector, I have implemented the methods and done the required task but now I want to learn how to make my code generic so I have tried many ways but non of them worked for me, you can see my code below:

Here is the statistic interface:


Here is the StatisticsCollector interface:


And here is the implementations:


---------------



---------------------


Can someone help please I have been trying and trying for days and nothing is working!
3 years ago