Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 09-02-2010
Member
 
Join Date: Dec 2009
Posts: 211
Multithreading and ArrayList

Hello,
I applied a small network or I find myself with a large quantity of objects. I made after a ping I find myself with about 1,000 IP addresses that are objects and that I would put in a collection but which one? Knowing that soon (not now I don t have time) I want to make multithreaded I think this is of use preferable Hashtable because I've started but with Vector, but it seems inadvisable because old and overused. I want to use multithreading with ArrayList, is this possible to do. If you have any solution for this, then please help me. I am interested in this.
Reply With Quote
  #2  
Old 09-02-2010
Member
 
Join Date: Nov 2009
Posts: 518
Re: Multithreading and ArrayList

Hello,
A Map (as Hashtable) is used to quickly access an object accurate a collection. If this is not your need, an ArrayList is sufficient. You will be able to synchronize with multithreading Collections.synchronizedList (..). I think you should go with this and I think you do not need multitasking for this. Still, if you use it, it is going to be tough for you to code for that.
Reply With Quote
  #3  
Old 09-02-2010
Member
 
Join Date: Dec 2009
Posts: 211
Re: Multithreading and ArrayList

Hello,
This is my code, see it and if you find any problems in it then correct me and guide me to the correct code.
Code:
Public void lancerScan(){
		String str = null;
		
			try
				{
				str = "Executable\\test.exe "+???????+"H-Temp\\Ping.txt ";



Runtime rntm = isp.getRuntime();
Process = isp launch.exec(str);/ / start of command
					launch.waitfor();/ / wait for the command is //finished to start another
					
		
				}
			
			catch(Exception e)
				{
					System.out.System.out.println("rntm error" + Cmd[i] + E.function toString() {
    [native code]
}());
				}
Reply With Quote
  #4  
Old 09-02-2010
Member
 
Join Date: Nov 2009
Posts: 356
Re: Multithreading and ArrayList

Hello,
I have modified your code, just go through it and then see if it works, for me it works here, but your needs may be different.
Code:
Public void uneM?thodeAppelante(){
   List lp = ....;
 .......

  for(int i =0; I <lp.size(); i + +)
  {
     lancerScan(lp.get(i));
  }
 
}
 
Public void lancerScan(String ip){
    String str = null;
    try
	{
	str = "Executable\\test.exe "ip + +"H-Temp\\Ping.txt ";
    Runtime runtime = isp.getRuntime();
Process = isp launch.exec(str);/ / start of command
	launch.waitfor();/ / wait for the command is finished to start another						
	}
    catch(Exception e)
	{
	System.out.System.out.println("runtime error" + Cmd[i] + E.function toString() {
    [native code]
}());
	}
}
Reply With Quote
  #5  
Old 09-02-2010
Member
 
Join Date: Dec 2009
Posts: 211
Re: Multithreading and ArrayList

Hello,
I did it like this to start the method and it works perfectly
Code:
{for(String e: ipls) 
	ip.lancerScan(e);
}
I am now trying to do the same thing by sending two things just like below but it does not work.
Code:
{for(String e: ipList, String f: getNameNetworks()) 
	ip.lancerScan(e, f);
}
If you know thank you very much knowing getNameNetworks returns a list
I continue my tests.
Reply With Quote
  #6  
Old 09-02-2010
Member
 
Join Date: Nov 2009
Posts: 333
Re: Multithreading and ArrayList

Hello,
I think using the following code you can get good performance by your code. Just have a look at it.
Here is the code
Code:
 
{
  for( Strinf f: getNameNetworks() )
  {
    for(String e: ipList)
    {
      ip.lancerScan(e, f);
    }
  }
}
By using the following code I think you can get a better performance from your program , I mean to say that your code will work much faster.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Multithreading and ArrayList"
Thread Thread Starter Forum Replies Last Post
Multithreading in intel IPP Assasin boy Motherboard Processor & RAM 9 26-09-2010 03:25 AM
run method of MultiThreading beelow Software Development 3 14-11-2009 10:18 AM
How to achieve Multithreading in Java LasitMalinga Software Development 3 02-05-2009 01:09 PM
Problem with Multithreading in C Language Jagdish Gada Software Development 4 09-03-2009 02:10 PM
forks and multithreading invincibledj20 Software Development 0 12-11-2008 07:55 PM


All times are GMT +5.5. The time now is 08:34 PM.