I've reattached two loose buttons with in a pinch. One with thread from my sewing kit and one with dental floss. While the floss is clearly stronger than the thread, the waxed floss button came undone in a week or two while the thread button is still good six months later.

Do you need to use the floss differently from thread to have it not come undone?