Thread: Now can i make a lot of threads of a same method?
Started 1 month ago by anonimo9999
Hi! I'm cooding an aplicattion that using only my method takes long time to be processed because it has to work with long text files (around 8 MB each file). Tha't because i've decided to take advantatge of multithreading but i don't know how to do that. I thougth in splitting the text file in smaller texts and working with them using the same method in multithreading and parallel so I've ...
First, creating that many threads is pointless. Second, allocating a thread also allocates 1MB of memory to go with it. So, if you actually had one thread running per object and had to process, say, 500 objects at once, you just ate up 500MB of RAM. Lastly, the largest number of threads you can use and still gain a performance benefit is the number of cores in your processor. Also, a hard ...
Mmmm it can be interesting... tomorrow i'll try it because now is time to go to sleep Seriously, because that program is for me and not to sell it I haven't thinked about RAM Anyway, I say you what the program does. Well what the program does is to take the text that i want of all the text file. In each text file there are a lot of lines and in each line there're some data separated by ...
Hi, multi-threading will increase overall performance as long as: 1) you have idle cores (e.g. your system is a quad core and there mainly is a single app, which isn't multi-threaded at all) 2) or your active cores are not fully loaded because a lot of time is spent waiting on something (disk I/O, network I/O, etc). You can check both by looking at the performance pane of Task Manager while ...
OK, having read the details now, I would not change a thing on your app. Look at Task Manager's performance pane and estimate average CPU load, lets say it is about 100%/Q (if Q is large, look again at your single-threaded code; don't use any Q higher than 5). Now split the files into Q folders, and run Q copies of your app at the same time, each dealing with one folder. That is about the best ...
Some suggestions that may improve performance, and are applicable to a single-threaded or multi-threaded app: 1. don't use regexes for this, they are powerful however they are slower than simple string logic; 2. don't use string.Split() if all you need is one part Hence, use an overload of string.IndexOf() to find the Nth comma; use another IndexOf() to find the next one, then use string....
Some suggestions that may improve performance, and are applicable to a single-threaded or multi-threaded app: 1. don't use regexes for this, they are powerful however they are slower than simple string logic; 2. don't use string.Split() if all you need is one part Hence, use an overload of string.IndexOf() to find the Nth comma; use another IndexOf() to find the next one, then use string.SubString BTW: this would fail if fields also...
Mmmm it can be interesting... tomorrow i'll try it because now is time to go to sleep Seriously, because that program is for me and not to sell it I haven't thinked about RAM Anyway, I say you what the program does. Well what the program does is to take the text that i want of all the text file. In each text file there are a lot of lines and in each line there're some data separated by commas representing they're columns...
First, creating that many threads is pointless. Second, allocating a thread also allocates 1MB of memory to go with it. So, if you actually had one thread running per object and had to process, say, 500 objects at once, you just ate up 500MB of RAM. Lastly, the largest number of threads you can use and still gain a performance benefit is the number of cores in your processor. Also, a hard drive can only read one area of the disk at a time, so...
Related threads on "CodeProject: Discussion Boards. Free source code and programming help":
When a method is called i want to get first index value... When a method is called i want to get first index value from an arraylist
and when the same methid is called nxt time i want to get the second index
value from the same arraylist...how?
Good news - Creative churches w/ a desire to reach... Good news - Creative churches w/ a desire to reach people. Bad news - Same method at the same time may lessen individual church impact.
11:04 AM Sep 7th from web
This sux,same method content copied and pasted... This sux,same method content copied and pasted everywhere. fixed one bug, trying to find out where else it can be the testers not spotted.
11:15 AM Oct 1st from web
Thread profile page for "Now can i make a lot of threads of a same method?" on http://www.codeproject.com.
This report page is a snippet summary view from a single thread "Now can i make a lot of threads of a same method?", located on the Message Board at http://www.codeproject.com.
This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity