Oh, finally somebody giving this a try.
The problem is that the texture is being created "out of context". The OpenGL context created by your RenderWindow is only active in the main thread, so the solution is to activate it in the worker thread before the texture is being loaded.
This
should work, but I have actually never tried it so far:
import org.jsfml.window.Context;[...
] // On another thread, create a Texture from an image file then cache it Thread worker
= new Thread(new Runnable() { public void run
() { Context context
= new Context(); Texture texture
= new Texture
(); try { texture.
loadFromFile(Paths.
get("canyonlands_large.jpg")); } catch (IOException e
) { e.
printStackTrace(); } cache.
put(KEY, texture
); } }); By creating an instance of the
Context class in the worker thread and by keeping it alive (by defining it for the entire run() method), the OpenGL context is activated for that thread and your texture should be created properly.
This should definitely be worth a Wiki article.