multithreading - Time based thread synchronization in java -


wondering if there time based synchronization in java. example below synchronization locks object , waits until //my application processor finishes task.

synchronize (myobject) {   //my application processor. } 

with same, there way synchronize 1 min or 2 min.

synchronize (only 1 min && object) {   //my application processor } 

or there other way in java synchronization method.

p.s: don't want run threadmanager monitor above. , don't want run while loop.

maybe looking java.util.concurrent.scheduledthreadpoolexecutor provides various ways of scheduling task performed/repeated in thread @ specified time/times in future.

maybe have method holds lock extended period of time (almost bad idea), , asking how abort operation , release lock if time limit reached. there couple of ways depending on takes time.

but guesses. haven't told problem trying solve.


your example of using "synchronized" timeout not make sense. purpose of "synchronized" protect data structures becoming corrupted. that's not want limited time.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -