[SPARK-3543] Write TaskContext in Java and expose it through a static accessor.

we should remove the object from thread local - otherwise it can lead to memory leak with the executor's thread pool being cached