Can you show us more detail - a fully compilable, runnable example that shows your problem (as simple as possible though, please). There isn't enough information to see where the problem lies in the code you posted.
See if you can't make the problem happen in some simple example. Showing code where it won't happen is not a help - since the problem obviously doesn't exist to be fixed. For one thing, the code you pasted doesn't use Threads, I assume from the title and location of this post that the error is occurring in a multi-threaded program. Try implementing the above code using multiple threads and see what you get.
Some things to take note though:
You call tc.sb.append("a") - using the sb variable outside a synchronized method call. Since sb is one of those objects you want to protect, it should only be called from inside a synchronized block or method.
I know this is a simple example, but you should keep the synchronized code to minimum needed to prevent inconsistent state. For example, in your code, depending on the expected behavior, you might want to shorten the parts of your code that are synchronized to just the parts that manipulate the StringBuffer and static integer. That depends on if you want all the work in one method to complete before the work in another method can begin...