hi,

so i have a question relating to sending data in a sequence. i have a class evenvent that reads the data from a txt file. that class has to send data to 2 comunication line async and sync. data sent to async is for ex: 'new' . data that is sent to sync is 'query' and it gets a result back

the data in txt file is in sequence 1,2,3,.... when i sent it to the 2 coommunication line i break the data and put it into 2 queues. one queue is for asyn and the oother is for sync. theses 2 class has to sent to another class A,

my question is how do i process the data in sequence again.

appreciate a way to do it

thanks

Recommended Answers

All 10 Replies

???? appreciate a way to do it

appreciate a reply

thanks,

Not sure what you are trying to do. What do you mean by "how do I process the data in sequence again"?

so i have 2 queues with data. data has a unique identification. i queue starts with 1,2,3,4, and then the next queues may have the 5 6 7data and so on. So when it comes to class B, it has to be in sequence so that class B can process it in order.

hope i made it clear

Sort the both the list for ascending

it is in acending order for ex: queue A has 1,2,3,4, 7,8 queue B has 5,6,9,10

it is like above

Hi,
It sounds so obvious that I probably miss the question :
Create another stack C.
Dequeue the first element from A (=>1) and B(=>5)
Compare these elements and enqueue the smaller into C (=>1)
Dequeue a new element from A (=>2) (because you have used the previous element from A)
And so on, when A and B are empty, you have a sorted stack C.

Hi,
It sounds so obvious that I probably miss the question :
Create another stack C.
Dequeue the first element from A (=>1) and B(=>5)
Compare these elements and enqueue the smaller into C (=>1)
Dequeue a new element from A (=>2) (because you have used the previous element from A)
And so on, when A and B are empty, you have a sorted stack C.
Patrick.

is there any solution for multiple threads?

Patrick, your soultion is for a single thread of control right?

If your stack A and B are located in distinct threads, each of these thread can write in a common C stack. But you must lock the C stack before writing in it. For this, I use Monitor.Enter(Cstack) to lock and Monitor.Exit(Cstack) when done, to free the data. Is this Monitor class clear for you ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.