Elegant way to transform Multi-thread into Single-thread
===

1.
I have main UI thread and it uses library functions.

    MainUI {
        library.funcA(1);
        library.funcB(2,3);
    }

I don't want Main-Thread to wait for the end of each call. Also creating new thread for each call is ineffective and not thread-safe so I want them to run on another same thread.
So I created another thread with a single message queue / handler.

    MainUI {
        handler.post(new Message(FUNC_A,[1]));
        handler.post(new Message(FUNC_B,[2,3]));
    }

but it seems having overhead that I need to create new Message object every time and decode it again in handleMessage(). Furthermore It looks ugly to handle the various number of arguments packing/unpacking. I thought making all functions as Runnable and post them to handler, but functions have different arguments and I need to make new classes extending Runnable class!

my current plan is to insert synchronized keywords into every function in library so threads run one by one,
but I dislike many threads creating/disappering so making system heavy (also not thread-safe). I want to hear opinions.

2.
if the library is called from many threads (not only Main-thread), what's the best way to convert calls to run on the library's own single thread?

