only use mutex for init on java platform, fixes #1732