Click here to Skip to main content
15,922,512 members
Home / Discussions / C#
   

C#

 
AnswerRe: sqlserver and msoffice Pin
Vasudevan Deepak Kumar27-Aug-07 23:23
Vasudevan Deepak Kumar27-Aug-07 23:23 
QuestionDateTime Format Pin
mihirhp27-Aug-07 18:19
mihirhp27-Aug-07 18:19 
AnswerRe: DateTime Format Pin
PIEBALDconsult27-Aug-07 18:22
mvePIEBALDconsult27-Aug-07 18:22 
AnswerRe: DateTime Format Pin
NaNg1524127-Aug-07 19:31
NaNg1524127-Aug-07 19:31 
AnswerRe: DateTime Format Pin
Vikram A Punathambekar27-Aug-07 19:35
Vikram A Punathambekar27-Aug-07 19:35 
QuestionDevExpress LookUpEdit Event Pin
~Alisa~Anny~27-Aug-07 17:56
~Alisa~Anny~27-Aug-07 17:56 
AnswerRe: DevExpress LookUpEdit Event Pin
Niranjan Kala16-May-11 3:17
Niranjan Kala16-May-11 3:17 
QuestionHow to do effective multithreading Pin
cyn827-Aug-07 16:48
cyn827-Aug-07 16:48 
hi,
i'm new to multithreading and i found it abit hard to understand. For example, i i were to have 3 thread which each prints the letter 'A','B' and 'C' respectively for 3 times(meaning, in total there should be 3 As,3 Bs and 3 Cs) and it is suppose to output as such ABCAABBCC. But how can i do it?
I thought of using Join method to ensure that the thread which writes A will execute the final 2 As and the same for Bs and Cs.....However, it does not seem to work... what should i take note of to ensure that it works accordingly?
Below are the codes that i've written wrongly i suppose.

using System;<br />
using System.Threading;<br />
<br />
namespace MultiThreading2<br />
{<br />
/// <summary><br />
/// Summary description for Class1.<br />
/// </summary><br />
class Class1<br />
{<br />
/// <summary><br />
/// The main entry point for the application.<br />
/// </summary><br />
[STAThread]<br />
static void Main(string[] args)<br />
{<br />
Thread t1=new Thread(new ThreadStart(WriteA));<br />
Thread t2=new Thread(new ThreadStart(WriteB));<br />
Thread t3=new Thread(new ThreadStart(WriteC));<br />
<br />
t1.Start();<br />
t2.Start();<br />
t3.Start();<br />
t1.Join();<br />
t2.Join();<br />
t3.Join();<br />
<br />
<br />
Console.ReadLine();<br />
}<br />
<br />
static void WriteA()<br />
{<br />
for(int i=0;i<3;i++)<br />
{Console.WriteLine("A");<br />
Thread.Sleep(2000);<br />
}<br />
<br />
<br />
}<br />
static void WriteB()<br />
{for(int j=0;j<3;j++)<br />
{<br />
Console.WriteLine("B");<br />
Thread.Sleep(2000);<br />
}<br />
<br />
<br />
}<br />
static void WriteC()<br />
{for(int k=0;k<3;k++)<br />
{<br />
Console.WriteLine("C");<br />
Thread.Sleep(2000);<br />
}<br />
<br />
}<br />
}<br />
}<br />


Thanks for any repliesSmile | :)
AnswerRe: How to do effective multithreading Pin
Luc Pattyn27-Aug-07 17:14
sitebuilderLuc Pattyn27-Aug-07 17:14 
QuestionC# and Java Pin
Adoremi27-Aug-07 16:38
Adoremi27-Aug-07 16:38 
AnswerRe: C# and Java Pin
Luc Pattyn27-Aug-07 17:07
sitebuilderLuc Pattyn27-Aug-07 17:07 
Question2 Question about using XML in C# Pin
Yanshof27-Aug-07 16:35
Yanshof27-Aug-07 16:35 
AnswerRe: 2 Question about using XML in C# Pin
Christian Graus27-Aug-07 20:07
protectorChristian Graus27-Aug-07 20:07 
Questionvideo capturing and sms feature Pin
4Hamburger27-Aug-07 15:49
4Hamburger27-Aug-07 15:49 
Questioncombobox.datasource question Pin
udikantz27-Aug-07 15:27
udikantz27-Aug-07 15:27 
AnswerRe: combobox.datasource question Pin
mihirhp27-Aug-07 20:28
mihirhp27-Aug-07 20:28 
GeneralRe: combobox.datasource question Pin
udikantz27-Aug-07 21:18
udikantz27-Aug-07 21:18 
GeneralRe: combobox.datasource question Pin
mihirhp27-Aug-07 22:24
mihirhp27-Aug-07 22:24 
QuestionActive Directory Pin
T4AMD27-Aug-07 14:08
T4AMD27-Aug-07 14:08 
AnswerRe: Active Directory Pin
ekynox27-Aug-07 15:52
ekynox27-Aug-07 15:52 
Questionnull exception while passing a serial port instance to an object Pin
murr00727-Aug-07 13:21
murr00727-Aug-07 13:21 
AnswerRe: null exception while passing a serial port instance to an object Pin
Luc Pattyn27-Aug-07 14:41
sitebuilderLuc Pattyn27-Aug-07 14:41 
GeneralRe: null exception while passing a serial port instance to an object Pin
murr00727-Aug-07 15:56
murr00727-Aug-07 15:56 
GeneralRe: null exception while passing a serial port instance to an object Pin
Luc Pattyn27-Aug-07 17:02
sitebuilderLuc Pattyn27-Aug-07 17:02 
QuestionHow can I prohibit writing a characters? Pin
daavena27-Aug-07 10:51
daavena27-Aug-07 10:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.