Load multiple files into Sybase and Threading Question

  • Thread starter Thread starter GG
  • Start date Start date
G

GG

I need to bcp into Sybase servers different files into different tables
simultaneasly. Is the following architecture thread safe?

1st Have a Helper Class that will take as a parameter the bcpCmd so we
can pass as paremeter to the thread
It looks like this
public class WorkToBeDone
{
string bcpCmd;
public WorkToBeDone(string server)
{
this.bcpCmd = bcpCmd;
}
public void WorkDone()
{
//create a process to call the bcpCmd
}
}


//main thread
WorkToBeDone bcp1 = new WorkToBeDone("bcp1cmd");
Thread bcp1T = new Thread (new ThreadStart(bcp1.WorkDone));
bcp1T.IsBackground=false;
bcp1T.Start();

WorkToBeDone bcp1 = new WorkToBeDone("bcp2cmd");
Thread bcp2T = new Thread (new ThreadStart(bcp1.WorkDone));
bcp2T.IsBackground=false;
bcp2T.Start();

and so on...

//join them as the last step so all work can be completed
bcp1T.Join();
bcp2T.Join();

//get time start and end of bcp1 and bcp2 ojbjects
//send an e-mail about the work done

Thanks
 
GG,

Without seeing what exactly WorkDone is going to do, it is hard to tell.
While bcp1 and bcp2 can't corrupt each other's state (they don't seem to
have a reference to each other), you have to make sure that whatever
resources they are accessing are thread-safe as well, in addition to the
code you are writing.

Hope this helps.
 
I was mostly concern with bcp1 and bcp2 objects.
Glad to hear that cannot corrupt each other.


Thanks for your reply.
 
GG,

The thing is, they can, depending on what that code is. I mean, they
might both access a static variable, they might have references to each
other, things of that nature.
 
Back
Top