Uh, I'm not sure what results you are getting but that code terminates during the first loop iteration. After printing out your "i = %d\n" line you call the pthread_exit(tid) function. This will nuke your main thread without ever executing multiple times.
Given that sample code, I don't see how you could have ever tested out 1024 thread creations. If you simply did a typo and meant for the pthread_exit() function to be called from your dummy() function, then I can see how you can get 1024 iterations of your loop.
I played around a little with your code presuming that you had intended for the pthread_exit() function to be called from within the dummy() function. On my test system here at work it seemed to work correctly. (Redhat 9 distro) however I have experienced your error condition in the past using a Fedora Core 4 distro. I traced it down to what looks like memory leaks in the libraries. The only way I could recover that memory was to re-boot my system.
It may be that.
I hope that this helps!