#include <glib-object.h>
#include <gio/gio.h>

#define THRCOUNT 1

static gpointer test_g_thread1(gpointer data)
{
    GError *err = NULL;
    GDBusConnection *conn = NULL;
    
    conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
    g_print("g_bus_get_sync \n");

    g_object_unref (conn);
}

static gpointer test_g_thread2(gpointer data)
{
    GDBusProxy *proxy;
    proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
                                           G_DBUS_PROXY_FLAGS_NONE,
                                           NULL,
                                           "org.freedesktop.DBus",
                                           "/org/freedesktop/DBus",
                                           "org.freedesktop.DBus",
                                           NULL,
                                           NULL);

    g_print ("g_dbus_proxy_new_for_bus\n");

    g_object_unref (proxy);
}




int main(int argc, char* argv[])
{
	GThread *threads1 [THRCOUNT];
	GThread *threads2 [THRCOUNT];
	guint i;

	//g_type_ensure (G_TYPE_DBUS_CONNECTION);
	//g_type_ensure (G_TYPE_DBUS_PROXY);

	for (i=0;i<THRCOUNT;i++)
	{
	        threads1[i] = g_thread_new("thread1", test_g_thread1, (gpointer)&i);
		threads2[i] = g_thread_new("thread2", test_g_thread2, (gpointer)&i);
	}

	for (i=0;i<THRCOUNT;i++) {
	  g_thread_join(threads1[i]);
	  g_thread_join(threads2[i]);
	}

	return 0;
}
