PC Review


Reply
Thread Tools Rate Thread

Converting a nested loop to use multithreading?

 
 
Richard Aubin
Guest
Posts: n/a
 
      14th Aug 2004
Hello all,

I have the following nested loop structure that I would love to convert to x
amount of threads:

For i = 0 To 100
For j = 0 To 100
For k = 0 To 100
Console.WriteLine("k = " & k)
Next
Console.WriteLine("j = " & j)
Next
Console.WriteLine("i =" & i)
Next

This process is based on existing code that I have that is taking well over
1 hour to complete.

Could someone provide me with example code to convert this to
multithreading, say 10 threads at once?


 
Reply With Quote
 
 
 
 
SStory
Guest
Posts: n/a
 
      15th Aug 2004
Hi Richard,

I don't have the code, but this raises an interesting question to me.

Doing 10 things simultaneously isn't necessary quicker and may actually be
slower... right or wrong?
Unless in each thread there is some latency time that the thread must wait
for I/O or something that another thread might be operating. Because unless
you have more than one processor, nothing actually happens at the same time,
just the process's time is divided per thread... am I right on this?

Sorry I don't have the code.. but also wanted to know an answer to my
question about your question.

Shane
"Richard Aubin" <rca_hyip@@hotmail.com> wrote in message
news:(E-Mail Removed)...
> Hello all,
>
> I have the following nested loop structure that I would love to convert to

x
> amount of threads:
>
> For i = 0 To 100
> For j = 0 To 100
> For k = 0 To 100
> Console.WriteLine("k = " & k)
> Next
> Console.WriteLine("j = " & j)
> Next
> Console.WriteLine("i =" & i)
> Next
>
> This process is based on existing code that I have that is taking well

over
> 1 hour to complete.
>
> Could someone provide me with example code to convert this to
> multithreading, say 10 threads at once?
>
>



 
Reply With Quote
 
Richard Aubin
Guest
Posts: n/a
 
      15th Aug 2004
Hello,

Yes, I am waiting for something to complete between loops.

"SStory" <(E-Mail Removed)> wrote in message
news:uyc2%(E-Mail Removed)...
> Hi Richard,
>
> I don't have the code, but this raises an interesting question to me.
>
> Doing 10 things simultaneously isn't necessary quicker and may actually be
> slower... right or wrong?
> Unless in each thread there is some latency time that the thread must wait
> for I/O or something that another thread might be operating. Because

unless
> you have more than one processor, nothing actually happens at the same

time,
> just the process's time is divided per thread... am I right on this?
>
> Sorry I don't have the code.. but also wanted to know an answer to my
> question about your question.
>
> Shane
> "Richard Aubin" <rca_hyip@@hotmail.com> wrote in message
> news:(E-Mail Removed)...
> > Hello all,
> >
> > I have the following nested loop structure that I would love to convert

to
> x
> > amount of threads:
> >
> > For i = 0 To 100
> > For j = 0 To 100
> > For k = 0 To 100
> > Console.WriteLine("k = " & k)
> > Next
> > Console.WriteLine("j = " & j)
> > Next
> > Console.WriteLine("i =" & i)
> > Next
> >
> > This process is based on existing code that I have that is taking well

> over
> > 1 hour to complete.
> >
> > Could someone provide me with example code to convert this to
> > multithreading, say 10 threads at once?
> >
> >

>
>



 
Reply With Quote
 
SStory
Guest
Posts: n/a
 
      15th Aug 2004
In that case, Chapter 19 of the Wrox "Professional VB.NET" book has code
that might be of use on how to do threading and thread pooling.

you can probably download the code from
www.wrox.com

maybe it would give you and idea.

HTH,

Shane
"Richard Aubin" <rca_hyip@@hotmail.com> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> Yes, I am waiting for something to complete between loops.
>
> "SStory" <(E-Mail Removed)> wrote in message
> news:uyc2%(E-Mail Removed)...
> > Hi Richard,
> >
> > I don't have the code, but this raises an interesting question to me.
> >
> > Doing 10 things simultaneously isn't necessary quicker and may actually

be
> > slower... right or wrong?
> > Unless in each thread there is some latency time that the thread must

wait
> > for I/O or something that another thread might be operating. Because

> unless
> > you have more than one processor, nothing actually happens at the same

> time,
> > just the process's time is divided per thread... am I right on this?
> >
> > Sorry I don't have the code.. but also wanted to know an answer to my
> > question about your question.
> >
> > Shane
> > "Richard Aubin" <rca_hyip@@hotmail.com> wrote in message
> > news:(E-Mail Removed)...
> > > Hello all,
> > >
> > > I have the following nested loop structure that I would love to

convert
> to
> > x
> > > amount of threads:
> > >
> > > For i = 0 To 100
> > > For j = 0 To 100
> > > For k = 0 To 100
> > > Console.WriteLine("k = " & k)
> > > Next
> > > Console.WriteLine("j = " & j)
> > > Next
> > > Console.WriteLine("i =" & i)
> > > Next
> > >
> > > This process is based on existing code that I have that is taking well

> > over
> > > 1 hour to complete.
> > >
> > > Could someone provide me with example code to convert this to
> > > multithreading, say 10 threads at once?
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Richard Aubin
Guest
Posts: n/a
 
      15th Aug 2004
Hi Shane,

That is exactly what I'm looking for.

Now all I have to do is dissect their code and apply it to my program.

Thanks!


"SStory" <(E-Mail Removed)> wrote in message
news:Oy$VG%(E-Mail Removed)...
> In that case, Chapter 19 of the Wrox "Professional VB.NET" book has code
> that might be of use on how to do threading and thread pooling.
>
> you can probably download the code from
> www.wrox.com
>
> maybe it would give you and idea.
>
> HTH,
>
> Shane
> "Richard Aubin" <rca_hyip@@hotmail.com> wrote in message
> news:(E-Mail Removed)...
> > Hello,
> >
> > Yes, I am waiting for something to complete between loops.
> >
> > "SStory" <(E-Mail Removed)> wrote in message
> > news:uyc2%(E-Mail Removed)...
> > > Hi Richard,
> > >
> > > I don't have the code, but this raises an interesting question to me.
> > >
> > > Doing 10 things simultaneously isn't necessary quicker and may

actually
> be
> > > slower... right or wrong?
> > > Unless in each thread there is some latency time that the thread must

> wait
> > > for I/O or something that another thread might be operating. Because

> > unless
> > > you have more than one processor, nothing actually happens at the same

> > time,
> > > just the process's time is divided per thread... am I right on this?
> > >
> > > Sorry I don't have the code.. but also wanted to know an answer to my
> > > question about your question.
> > >
> > > Shane
> > > "Richard Aubin" <rca_hyip@@hotmail.com> wrote in message
> > > news:(E-Mail Removed)...
> > > > Hello all,
> > > >
> > > > I have the following nested loop structure that I would love to

> convert
> > to
> > > x
> > > > amount of threads:
> > > >
> > > > For i = 0 To 100
> > > > For j = 0 To 100
> > > > For k = 0 To 100
> > > > Console.WriteLine("k = " & k)
> > > > Next
> > > > Console.WriteLine("j = " & j)
> > > > Next
> > > > Console.WriteLine("i =" & i)
> > > > Next
> > > >
> > > > This process is based on existing code that I have that is taking

well
> > > over
> > > > 1 hour to complete.
> > > >
> > > > Could someone provide me with example code to convert this to
> > > > multithreading, say 10 threads at once?
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
SStory
Guest
Posts: n/a
 
      17th Aug 2004
It is a pretty decent book Not bad for a reference... If you decide to buy
a copy--for sure buy online..the book is like $60 in Books a million but if
you get there discount card and order online it is at least half that price.

Glad to help you,

Shane

"Richard Aubin" <rca_hyip@@hotmail.com> wrote in message
news:(E-Mail Removed)...
> Hi Shane,
>
> That is exactly what I'm looking for.
>
> Now all I have to do is dissect their code and apply it to my program.
>
> Thanks!
>
>
> "SStory" <(E-Mail Removed)> wrote in message
> news:Oy$VG%(E-Mail Removed)...
> > In that case, Chapter 19 of the Wrox "Professional VB.NET" book has code
> > that might be of use on how to do threading and thread pooling.
> >
> > you can probably download the code from
> > www.wrox.com
> >
> > maybe it would give you and idea.
> >
> > HTH,
> >
> > Shane
> > "Richard Aubin" <rca_hyip@@hotmail.com> wrote in message
> > news:(E-Mail Removed)...
> > > Hello,
> > >
> > > Yes, I am waiting for something to complete between loops.
> > >
> > > "SStory" <(E-Mail Removed)> wrote in

message
> > > news:uyc2%(E-Mail Removed)...
> > > > Hi Richard,
> > > >
> > > > I don't have the code, but this raises an interesting question to

me.
> > > >
> > > > Doing 10 things simultaneously isn't necessary quicker and may

> actually
> > be
> > > > slower... right or wrong?
> > > > Unless in each thread there is some latency time that the thread

must
> > wait
> > > > for I/O or something that another thread might be operating.

Because
> > > unless
> > > > you have more than one processor, nothing actually happens at the

same
> > > time,
> > > > just the process's time is divided per thread... am I right on this?
> > > >
> > > > Sorry I don't have the code.. but also wanted to know an answer to

my
> > > > question about your question.
> > > >
> > > > Shane
> > > > "Richard Aubin" <rca_hyip@@hotmail.com> wrote in message
> > > > news:(E-Mail Removed)...
> > > > > Hello all,
> > > > >
> > > > > I have the following nested loop structure that I would love to

> > convert
> > > to
> > > > x
> > > > > amount of threads:
> > > > >
> > > > > For i = 0 To 100
> > > > > For j = 0 To 100
> > > > > For k = 0 To 100
> > > > > Console.WriteLine("k = " & k)
> > > > > Next
> > > > > Console.WriteLine("j = " & j)
> > > > > Next
> > > > > Console.WriteLine("i =" & i)
> > > > > Next
> > > > >
> > > > > This process is based on existing code that I have that is taking

> well
> > > > over
> > > > > 1 hour to complete.
> > > > >
> > > > > Could someone provide me with example code to convert this to
> > > > > multithreading, say 10 threads at once?
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Do I need a Nested Loop? =?Utf-8?B?bm9tYWRr?= Microsoft Access VBA Modules 14 16th Nov 2007 03:35 PM
Nested loop =?Utf-8?B?S0otY2x1ZWxlc3M=?= Microsoft Access VBA Modules 3 18th Apr 2007 10:28 PM
Nested Loop JMay Microsoft Excel Programming 4 17th Dec 2006 11:19 PM
Convert loop with Match function to avoid nested loop??? Kobayashi Microsoft Excel Programming 2 17th Mar 2004 06:36 PM
Nested Loop?? Carol Microsoft Access Form Coding 2 25th Aug 2003 06:25 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:55 AM.