MinecraftShamrock
MinecraftShamrock

Reputation: 3574

Java - How to access static synchronized method from another Thread?

I'm using an API that provides a static synchronized method and I need to call it from another Thread. Always when I call it from another thread it throws an Exception with a message like that

Can't access this method from another thread!

What I tried was to put the method call into a synchronized block. But since it is a static method there is nothing to put into the static block.

So how can I access a static synchronized method from another thread?

UPDATE: I'm coding a Bukkit plugin (minecraft) and the API is called TagAPI.

Upvotes: 2

Views: 270

Answers (1)

Thomas Mueller
Thomas Mueller

Reputation: 50127

If the library checks that you are calling the method from a specific thread, then most likely there is a good reason for that, and therefore you should not do it.

Upvotes: 2

Related Questions