career_cup_18_5

Suppose we have the following code:
  class Foo {
  public:
A(.....); /* If A is called, a new thread will be created and * the
corresponding function will be executed. */
B(.....); /* same as above */
C(.....); /* same as above */ }
Foo f; f.A(.....); f.B(.....); f.C(.....);
i) Can you design a mechanism to make sure that B is executed after A,
and C is ex- ecuted after B?
iii) Suppose we have the following code to use class Foo We do not know
how the threads will be scheduled in the OS
Foo f;
f.A(.....); f.B(.....); f.C(.....); f.A(.....); f.B(.....); f.C(.....);
Can you design a mechanism to make sure that all the methods will be
executed in sequence?