473,498 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Consecutive threads

As shown below, the genetic algorithm is applied to consecutive objects
The next calculation should not begin until the previous calculation ends

However, without any code between ...., calculation thread is generated simulataneously
As I monitor ts(ThreadState), it maintains constantly 'Background, Unstarted' even in the end of the calculation
If I insert while loop the thread does not start

If I use Thread.IsAlive, it works good. It shows 'false' when the calculation is terminated
But, I have no idea to apply this property to my code without while loop

How can I do that? Is an event in need
foreach (object o in objects

Calculate calc = new Calculate(o)

Thread t = calc.
ThreadState ts = t.ThreadStat
...
calc.Start()
...
class Calculatio

public Thread T {get {return t;}

public void Start(

t = new Thread(new ThreadStart(Evolution))
t.IsBackground = true
t.Start()
// Genetic algorith
private void Evolution(

.............

}
Nov 16 '05 #1
3 1726
I think you can create a sync object to lock from one thread.
What you do is create an object and then when a thread starts it locks the
object and releases the lock it when it ends.
Then the other thread has to wait until the object is not locked.
I could be way off base here because I have not done much threading.
Have a look at locks and threading in google and MSDN.

HTH
JB

What is the question?
That is the question.

"choyk1" <ch****@bmdrc.org> wrote in message
news:4E**********************************@microsof t.com...
As shown below, the genetic algorithm is applied to consecutive objects.
The next calculation should not begin until the previous calculation ends.

However, without any code between ...., calculation thread is generated simulataneously. As I monitor ts(ThreadState), it maintains constantly 'Background, Unstarted' even in the end of the calculation. If I insert while loop the thread does not start.

If I use Thread.IsAlive, it works good. It shows 'false' when the calculation is terminated. But, I have no idea to apply this property to my code without while loop.

How can I do that? Is an event in need?

foreach (object o in objects)
{
Calculate calc = new Calculate(o);

Thread t = calc.T
ThreadState ts = t.ThreadState
....
calc.Start();
....
}

class Calculation
{
public Thread T {get {return t;}}

public void Start()
{
t = new Thread(new ThreadStart(Evolution));
t.IsBackground = true;
t.Start();
}

// Genetic algorithm
private void Evolution()
{
..............
}
}

Nov 16 '05 #2
choyk1 <ch****@bmdrc.org> wrote:
As shown below, the genetic algorithm is applied to consecutive objects.
The next calculation should not begin until the previous calculation ends.


In that case, I suggest you don't use multiple threads in the first
place. Performing several consecutive calculations is exactly what a
single thread does best.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3
Choyk1,
I see you dont need parallelism in your application. Is there a
reasnon why you would use threads?
choyk1 wrote:
As shown below, the genetic algorithm is applied to consecutive objects.
The next calculation should not begin until the previous calculation ends.

However, without any code between ...., calculation thread is generated simulataneously.
As I monitor ts(ThreadState), it maintains constantly 'Background, Unstarted' even in the end of the calculation.
If I insert while loop the thread does not start.

If I use Thread.IsAlive, it works good. It shows 'false' when the calculation is terminated.
But, I have no idea to apply this property to my code without while loop.

How can I do that? Is an event in need?

foreach (object o in objects)
{
Calculate calc = new Calculate(o);

Thread t = calc.T
ThreadState ts = t.ThreadState
....
calc.Start();
....
}

class Calculation
{
public Thread T {get {return t;}}

public void Start()
{
t = new Thread(new ThreadStart(Evolution));
t.IsBackground = true;
t.Start();
}

// Genetic algorithm
private void Evolution()
{
..............
}
}


--
Regards,
Dilip Krishnan
MCAD, MCSD.net
dilipdotnet at apdiya dot com
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3001
by: Adam | last post by:
Hi, I am trying to mark consective numbers in a data set and get a count as to how many consecutive numbers exist in the a given line of data. Here is an example line: 3, 5, 7, 9, 10, 13,...
3
273
by: choyk1 | last post by:
As shown below, the genetic algorithm is applied to consecutive objects The next calculation should not begin until the previous calculation ends However, without any code between ....,...
2
2932
by: Beliavsky | last post by:
How can I replace multiple consecutive spaces in a file with a single character (usually a space, but maybe a comma if converting to a CSV file)? Ideally, the Python program would not compress...
7
11307
by: Sharkie | last post by:
I need a regular expression which will evaluate to false if number of consecutive characters (non-whitespace) exceeds certain number (10 in this example). For example, I have this function: ...
6
2910
by: cesco | last post by:
Hi, say I have a vector like the following: vec = and I'd like to know via a function (for example, ConsecutiveIntegers(vec, N)) whether there are N consecutive integers. So, for example,...
1
1566
by: Mike | last post by:
Hi All, I'm using vb.net as my codebehind lang. and the following code is being executed in my aspx.vb page to stamp a DB row. Dim oStatsInfo As New StatsInfo(CartID, Batch, Set, Num, 0, 0, 0,...
16
2369
by: sloan | last post by:
Current Framework 2.0/3.0. ... In Sql Server, there is a way to generate consecutive guid's. newsequentialid. Is there a way to reproduce this type of consecutive guid's in the framework.
8
12906
by: gigonomics | last post by:
Hi all, I hope someone can help me out. I need to return the best available seats subject to the constraint that the seats are side by side (or return X consecutive records from a table column...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7167
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7208
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6890
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4915
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4593
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1423
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
657
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.